Results 1 to 3 of 3
  1. #1
    kskgupta is offline Member
    Join Date
    May 2010
    Posts
    1
    Rep Power
    0

    Default reading values into variables using java

    i,m very new to java how read values into variables using java and i want to know about Exception handling and about threads

  2. #2
    Webuser is offline Senior Member
    Join Date
    Dec 2008
    Posts
    526
    Rep Power
    0

    Lightbulb

    well I can recommend read sun tutorials first and get some books. Just google it

    i,m very new to java how read values into variables
    it is called initialize variables ;)

    int a=10; Something like that or String a="10";
    If my answer helped you. Please click my "REP" button and add a comment
    Have a Good Java Coding :)

  3. #3
    somanayr is offline Member
    Join Date
    May 2010
    Posts
    27
    Rep Power
    0

    Default

    Do you mean reading variables from the consol?

    First, you need to add to the header (very very top, even above public class):
    Java Code:
    import java.util.Scanner;
    then, in your main, add
    Java Code:
    Scanner input = new Scanner(System.in);
    to read variable input from the consol, follow this example:
    Java Code:
    int a = input.nextInt()
    to change the type of thing to read use next() for strings and nextFloat() for floats (be sure to change the variable type as well!)

Similar Threads

  1. Replies: 1
    Last Post: 03-08-2010, 06:25 PM
  2. Replies: 3
    Last Post: 08-24-2009, 07:39 PM
  3. Help in reading values from html form in java
    By ichkoguy in forum Advanced Java
    Replies: 7
    Last Post: 03-16-2009, 07:45 AM
  4. [SOLVED] Debug: values not shown for variables
    By jwilley44 in forum Eclipse
    Replies: 7
    Last Post: 01-30-2009, 03:33 AM
  5. Replies: 2
    Last Post: 08-03-2007, 04:06 PM

Posting Permissions

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