class UnresponsiveUI
{
private volatile double d = 1;
public UnresponsiveUI() throws Exception
{
while(d > 0)
{
d = d + (Math.PI + Math.E) / d;
System.in.read();
System.out.println(d);
}
}
} public static void main(String[] args) throws Exception
{
new UnresponsiveUI(); // Must kill this process
//new ResponsiveUI();
//System.in.read();
//System.out.println(d);
}
}
在控制台输入1,为什么一下子打印出来:
6.859874482048838
7.714099220035395
8.473730943053596
{
private volatile double d = 1;
public UnresponsiveUI() throws Exception
{
while(d > 0)
{
d = d + (Math.PI + Math.E) / d;
System.in.read();
System.out.println(d);
}
}
} public static void main(String[] args) throws Exception
{
new UnresponsiveUI(); // Must kill this process
//new ResponsiveUI();
//System.in.read();
//System.out.println(d);
}
}
在控制台输入1,为什么一下子打印出来:
6.859874482048838
7.714099220035395
8.473730943053596
while(d > 0)
{
d = d + (Math.PI + Math.E) / d; InputStreamReader isr = new InputStreamReader(System.in);
BufferedReader br = new BufferedReader(isr);
String test = null;
try {
test = br.readLine();
while(test!=null){
System.out.println(test);
System.out.println(d);
test = br.readLine();
}
br.close();
}catch (IOException e) {
e.printStackTrace();
}
}
import java.util.Scanner;public class UnresponsiveUI {
private volatile double d = 1;
public UnresponsiveUI() throws Exception
{
Scanner s = new Scanner(System.in);
System.out.println("请输入数字,回车确定:"); while(d > 0)
{
d=s.nextDouble();
d = d + (Math.PI + Math.E) / d;
// java.util.Scanner scanner=new Scanner();
System.out.println(d);
}
}
public static void main(String[] args) throws Exception
{
new UnresponsiveUI(); // Must kill this process
//new ResponsiveUI();
//System.in.read();
//System.out.println(d);
}}