Results 1 to 7 of 7
  1. #1
    PlzHelpMe is offline Member
    Join Date
    Sep 2011
    Posts
    3
    Rep Power
    0

    Default 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!!

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,315
    Blog Entries
    1
    Rep Power
    26

    Default 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.

  3. #3
    mine0926 is offline Senior Member
    Join Date
    Apr 2010
    Location
    Philippines
    Posts
    580
    Rep Power
    5

    Default Re: Many questions about Java coding

    First of all, what is a "Scanner object"? and why do you need to create one?
    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.

    In "Scanner s = new Scanner(System.in);" What does the 's' stand for?
    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.
    's' is the name you assign in Scanner class, and will be use to call the methods available by class.

    And what's the difference between a integer variable and a String variable?
    And how do you know which one to use?
    String is a text while integer is number. You will not think that 'abc123' is a number right??

    What do these mean: "s.nextInt();" and "s.nextLine();"
    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.

    And in String someText = What does "someText" stand for?
    someText is the assigned name of String.


    Recommended reading
    The Really Big Index

  4. #4
    PlzHelpMe is offline Member
    Join Date
    Sep 2011
    Posts
    3
    Rep Power
    0

    Default 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:

  5. #5
    sunde887's Avatar
    sunde887 is offline Moderator
    Join Date
    Jan 2011
    Location
    Richmond, Virginia
    Posts
    3,069
    Blog Entries
    3
    Rep Power
    8

    Default Re: Many questions about Java coding

    I'd suggest getting head first java; or go to the really big index above.

  6. #6
    mine0926 is offline Senior Member
    Join Date
    Apr 2010
    Location
    Philippines
    Posts
    580
    Rep Power
    5

    Default Re: Many questions about Java coding

    Quote Originally Posted by Fubarable View Post
    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.
    Oh no! You think this is an assignment?

  7. #7
    PlzHelpMe is offline Member
    Join Date
    Sep 2011
    Posts
    3
    Rep Power
    0

    Default Re: Many questions about Java coding

    I do have an assignment due for school, but in order to do the assignment, I must understand the meanings of things. That's why I came here, because I am completely lost. I am not asking for answers, just definitions.

Similar Threads

  1. Coding sms in java?
    By strictlydivine.elite in forum Advanced Java
    Replies: 2
    Last Post: 11-18-2010, 03:10 PM
  2. Replies: 4
    Last Post: 10-25-2010, 04:49 PM
  3. questions about coding standards
    By gib65 in forum New To Java
    Replies: 22
    Last Post: 09-20-2010, 10:39 AM
  4. java coding
    By zawad in forum Suggestions & Feedback
    Replies: 1
    Last Post: 07-07-2009, 02:55 PM
  5. Coding Java on a Mac
    By Menre in forum New To Java
    Replies: 5
    Last Post: 05-06-2008, 06:49 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •