java问题
各位大哥救命啊!请问用java语言编程时,怎么从窗口读取一行字符啊??还有,读取到的字符要怎么样转换成整型数值,还是不用转换都可以的??
以下是在JDK5.0下
import java.util.*;
public class InputTest
{
public static void main(String[] args)
{
Scanner in =new Scanner(System.in);
System.out.print("What's your name:");
String name=in.nextLine();
System.out.print("How old are you:");
int age=in.nextInt();
System.out.println("Hellow "+name+",your age is "+age);
}
}
你看一下
}