ermm,i want to noe the code for reading in the first alphabet as a input only.
eg: NAME den take in N only....help me?...lol..
For I/O, http://pages.cs.wisc.edu/~cs302/io/JavaIO.html
For string, http://www.javabeginner.com/java-string-class.htm
These 2 pages should have all the codes you would need.
I hope tat was not homework ...
Originally posted by Evo4eva:ermm,i want to noe the code for reading in the first alphabet as a input only.
eg: NAME den take in N only....help me?...lol..
Assuming you already know how to get input using the Scanner class, just chain the charAt() method after calling the next() method.
http://forums.macrumors.com/showthread.php?t=148798#post_message_1729620
More information about the charAt() method here.
http://java.sun.com/j2se/1.4.2/docs/api/java/lang/String.html#charAt(int)
Basically, what you are doing here is, when you call the next() method, it returns a String object which contains the input from the user (it's actually a token of the user input but we won't talk about it here). The charAt() method, coming from the String class, allows you to pick a character out of a String object. Say, for example, a user types in "sgForums" as input. If I want to retrieve the 3rd letter 'F', the offset of the letter would be 2 (skip 2 letters), thus I would call next().charAt(2) from a Scanner object.
If you don't understand any part of my post, please don't hesitate to clarify with me.
thx...help alot....![]()
ermmm,it is not homework,just wanna try this method in my assignment thingy...lol...
D: