storing input in an int.

someone on another forum said that when you want to store input in an int you have to use something like this:

BufferedReader br =new BufferedReader(new InputStreamReader(System.in));

input = Integer.parseInt(br.readLine());

amnd u have to import "java.io"

my first question is: how do you import java.io?

i typed this:

package java.io;

is this correct? it says: "Class, interface or enum expected."

whats wrong?

and second: is it correct what the person on the other forum said? because to me it looks a bit long and complicated for something that's so basic. in c++ its just cin <<. thats much more basic.

[775 byte] By [omniscienta] at [2007-11-27 6:21:57]
# 1
import java.io.;you can use Scanner class instead for J5+.
TuringPesta at 2007-7-12 17:38:47 > top of Java-index,Java Essentials,New To Java...
# 2

import java.util.Scanner;

class Test {

public static void main(String[] args) {

Scanner s = new Scanner(System.in);

int input;

System.out.println("Enter a number ");

input = s.nextInt();

System.out.println("You entered: " + input );

}

}

Like turningpest Said you can use scanner with version 5

fastmikea at 2007-7-12 17:38:47 > top of Java-index,Java Essentials,New To Java...
# 3
J5+?
omniscienta at 2007-7-12 17:38:47 > top of Java-index,Java Essentials,New To Java...
# 4
yes java version 5
fastmikea at 2007-7-12 17:38:47 > top of Java-index,Java Essentials,New To Java...
# 5
thanks, it works.
omniscienta at 2007-7-12 17:38:47 > top of Java-index,Java Essentials,New To Java...
# 6
use import java.io.BufferedReader;if you want to use the existing package then use import statement.If you want to create a package then only use Package statement
Saikumara at 2007-7-12 17:38:47 > top of Java-index,Java Essentials,New To Java...