Results 1 to 3 of 3
  1. #1
    yssilleahcar is offline Member
    Join Date
    Nov 2014
    Posts
    1
    Rep Power
    0

    Red face How do I get user input?

    Hello guys, I am fairly new in java, I have been coding in my class at school (Grade 11 Computer science) and i just downloaded the program on my computer at home, unfortunately i cannot access my computer notes at home and i also dont remember certian specifics of coding, so my question is how would i get user input to create a program. The comments are the parts i dont remember. (I am trying to slowly build my memory with this stuff)
    Thanks So much for your help!
    Here is my code so far:
    import java.util;
    [highlight=java]

    public class hello_world {

    public static void main(String[] args) {
    string name;

    //WHAT DO I PUT HERE????
    System.out.print("Please type your name: ");
    //And here????
    input.close();
    System.out.println("Hello," + name);
    }
    }
    [/highlight]

    oh and there may be a few coding errors in here, if so do you mind pointing them out to me? thanks
    -newbie with no notes :(
    Last edited by yssilleahcar; 11-13-2014 at 03:06 AM.

  2. #2
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    20,003
    Rep Power
    33

    Default Re: How do I get user input?

    Please edit your post and wrap your code with highlight tags:
    [highlight=java]
    YOUR CODE GOES HERE
    [/highlight]
    to get highlighting and preserve formatting.

    how would i get user input
    See the Scanner class for some methods that could be useful.
    If you don't understand my response, don't ignore it, ask a question.

  3. #3
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    5,114
    Rep Power
    12

    Default Re: How do I get user input?

    Do an exercise: literally type "java get user input" into Google. See what you get.

    Hint: you are not the first person who asks this, so the answer is most likely already floating out there about a thousand times. Finding one is much faster than having to wait for an answer in a forum.
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

Similar Threads

  1. User Input???
    By jonytek in forum New To Java
    Replies: 8
    Last Post: 01-13-2013, 03:52 PM
  2. Help with user input
    By sconniegorilla in forum New To Java
    Replies: 2
    Last Post: 02-16-2011, 03:00 PM
  3. Need help getting input(first/last name) from user
    By nightrise420 in forum New To Java
    Replies: 11
    Last Post: 09-11-2010, 04:09 AM
  4. User Input
    By brmcdani in forum New To Java
    Replies: 2
    Last Post: 02-05-2010, 02:59 AM
  5. cant take input from user
    By new_1 in forum New To Java
    Replies: 6
    Last Post: 12-25-2007, 08:38 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
  •