2019独角兽企业重金招聘Python工程师标准>>>
public class Test {
public static void main(String args[])
{
long time = System.currentTimeMillis();
for(long i=0; i< 2000000000; i++)
{
if(false){String s = null;}
else{String s = null;};
}
System.out.println("'if else':用时"+(System.currentTimeMillis()-time)/1000.0+"秒");
}
}
Test2:
public class Test2 {
public static void main(String args[])
{
long time = System.currentTimeMillis();
for(double i=0; i< 2000000000; i++)
{
String s = false?null:null;
}
System.out.println("'三元运算符':用时"+(System.currentTimeMillis()-time)/1000.0+"秒");
}
}