程序原代码:public class Test3 { public static void main(String[] args) { String src = System.console().readLine(); int i = Integer.parseInt(src);//This method will give the failed reason. String aim = ""; while (i > 1) { aim = i % 2 + aim; i /= 2; } aim = i+aim; System.out.println(aim); } }
console public static Console console()Returns the unique Console object associated with the current Java virtual machine, if any. Returns: The system console, if any, otherwise null. Since: 1.6 jdk1.6才支持!
还是ArrayList等的clone()?
public static void main(String[] args) {
String src = System.console().readLine();
int i = Integer.parseInt(src);//This method will give the failed reason.
String aim = "";
while (i > 1) {
aim = i % 2 + aim;
i /= 2;
}
aim = i+aim;
System.out.println(aim);
}
}
public static Console console()Returns the unique Console object associated with the current Java virtual machine, if any. Returns:
The system console, if any, otherwise null.
Since:
1.6 jdk1.6才支持!