Results 1 to 7 of 7
Thread: Many questions about Java coding
- 09-16-2011, 02:12 AM #1
Member
- Join Date
- Sep 2011
- Posts
- 3
- Rep Power
- 0
Many questions about Java coding
I'm having a really hard time understanding basic Java programming.
First of all, what is a "Scanner object"? and why do you need to create one?
In "Scanner s = new Scanner(System.in);" What does the 's' stand for?
And what's the difference between a integer variable and a String variable?
And how do you know which one to use?
What do these mean: "s.nextInt();" and "s.nextLine();"
I know that the first one is used for integers and the second one for strings, but why do you need to type them?
And in String someText = What does "someText" stand for?
Thank you!!
-
Re: Many questions about Java coding
To get the most from this exercise, why not tell us what you think the answers to this assignment are first? That way you'll understand things much better, and we'll have a better idea of where you're stuck.
- 09-16-2011, 02:41 AM #3
Senior Member
- Join Date
- Apr 2010
- Location
- Philippines
- Posts
- 580
- Rep Power
- 4
Re: Many questions about Java coding
For correction only, we do not need to create Scanner class. We create a class (like Scanner) to do specific task that a certain class can provide.First of all, what is a "Scanner object"? and why do you need to create one?
Scanner is a class that provide various methods (these methods provides specific process), most of these methods deals on reading user inputs, files etc. In your case you assign or tell to Scanner class to read from user's input.In "Scanner s = new Scanner(System.in);" What does the 's' stand for?
's' is the name you assign in Scanner class, and will be use to call the methods available by class.
String is a text while integer is number. You will not think that 'abc123' is a number right??And what's the difference between a integer variable and a String variable?
And how do you know which one to use?
nextInt() and nextLine() are the methods I am telling to you (methods that are available in Scanner class). These methods will look for user's input.What do these mean: "s.nextInt();" and "s.nextLine();"
someText is the assigned name of String.And in String someText = What does "someText" stand for?
Recommended reading
The Really Big Index
- 09-16-2011, 02:47 AM #4
Member
- Join Date
- Sep 2011
- Posts
- 3
- Rep Power
- 0
Re: Many questions about Java coding
Trust me, I'm a total n00b to Java so what I think might make absolutely no sense. In my opinion, you type "Scanner" so the computer can understand the word you made up as an identifier?
I think the 's' might stand for String? So it's the scanner of a bunch of words?
An integer variable is used for numbers? and a String variable is used for letters?
"s.nextInt();" and "s.nextLine();" are placed at the end of an integral and String...but I have no idea what they can do. Maybe the act like the ending of a code?
And "someText" stands for any text you want to type?
I think I'm going to buy "Java for Dummies" D:
- 09-16-2011, 02:51 AM #5
- Join Date
- Jan 2011
- Location
- Richmond, Virginia
- Posts
- 3,069
- Blog Entries
- 3
- Rep Power
- 7
Re: Many questions about Java coding
I'd suggest getting head first java; or go to the really big index above.
- 09-16-2011, 02:52 AM #6
Senior Member
- Join Date
- Apr 2010
- Location
- Philippines
- Posts
- 580
- Rep Power
- 4
- 09-16-2011, 02:54 AM #7
Member
- Join Date
- Sep 2011
- Posts
- 3
- Rep Power
- 0
Similar Threads
-
Coding sms in java?
By strictlydivine.elite in forum Advanced JavaReplies: 2Last Post: 11-18-2010, 02:10 PM -
does gui coding in netbeans is just the same with coding without nebeans?
By maizuddin35 in forum NetBeansReplies: 4Last Post: 10-25-2010, 03:49 PM -
questions about coding standards
By gib65 in forum New To JavaReplies: 22Last Post: 09-20-2010, 09:39 AM -
java coding
By zawad in forum Suggestions & FeedbackReplies: 1Last Post: 07-07-2009, 01:55 PM -
Coding Java on a Mac
By Menre in forum New To JavaReplies: 5Last Post: 05-06-2008, 05:49 AM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks