日期:2014-05-20  浏览次数:20750 次

java怎么输出?
比如scanf("%d",&a);怎么用java写?
------解决方案--------------------
http://www.cnblogs.com/ydpvictor/archive/2012/06/17/2552981.html
这种问题自己搜!
------解决方案--------------------
用Scanner去实现吧
------解决方案--------------------
接收键盘输入?用Scanner,举个栗子:

Scanner sc=new Scanner(System.in);
System.out.println("给个提示,用户要输入:");
String a=sc.next();
System.out.println(a);  //刚在控制台输入的什么,就打印什么的

Scanner 的对象又一系列重载方法,可以接收多种类型的数据,类似c语言中的%f,%d等等:

String next() 
Finds and returns the next complete token from this scanner.
String next(Pattern pattern)
Returns the next token if it matches the specified pattern.
String next(String pattern)
Returns the next token if it matches the pattern constructed from the specified string.
BigDecimal nextBigDecimal()
Scans the next token of the input as a BigDecimal.
BigInteger nextBigInteger()
Scans the next token of the input as a BigInteger.
BigInteger nextBigInteger(int radix)
Scans the next token of the input as a BigInteger.
boolean nextBoolean()
Scans the next token of the input into a boolean value and returns that value.
byte nextByte()
Scans the next token of the input as a byte.
byte nextByte(int radix)
Scans the next token of the input as a byte.
double nextDouble()
Scans the next token of the input as a double.
float nextFloat()
Scans the next token of the input as a float.
int nextInt()
Scans the next token of the input as an int.
int nextInt(int radix)
Scans the next token of the input as an int.
String nextLine()
Advances this scanner past the current line and returns the input that was skipped.
long nextLong()
Scans the next token of the input as a long.
long nextLong(int radix)
Scans the next token of the input as a long.
short nextShort()
Scans the next token of the input as a short.
short nextShort(int radix)
Scans the next token of the input as a short.