a=a+1;a+=1;a++ 那个性能高呀??为什么? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 a++ 更多的JAVA面试题,Java代码,Java学习资料,请到:JAVA世纪网更多的数据库面试题,智力面试题,相声,笑话,请到:老紫竹的家 a++数据在电脑中是以二进制来存的,如果用a ++ 的话直接对a 的二进制的值的未位进行+1,不用再定义一个1,其他的好像都要再定义一个1 public class Test { public static void main(String [] args) throws Exception{ int x=1; x=x+1; int y=1; y+=1; int z=1; z++; } } public class Test{ public Test() { // 0 0:aload_0 // 1 1:invokespecial #1 <Method void Object()> // 2 4:return } public static void main(String args[]) throws Exception { int i = 1; // 0 0:iconst_1 // 1 1:istore_1 i++; // 2 2:iload_1 // 3 3:iconst_1 // 4 4:iadd // 5 5:istore_1 int j = 1; // 6 6:iconst_1 // 7 7:istore_2 j++; // 8 8:iinc 2 1 int k = 1; // 9 11:iconst_1 // 10 12:istore_3 k++; // 11 13:iinc 3 1 // 12 16:return }}比比谁的效率高。 a++的性能高 a++是在内存里面对他的值操作 不用改变a的引用地址所以性能高 以前学习了,之前忘了,现在又学习了!Upa++和++a再大型的程序设计里还是又区别的,对整体的效率影响很大! 冒泡排序求解 JAVA 线程监控 匿名内部类是否可以实现接口??? JAVA关于输出语句的弱智问题 怪!! 从数据库读出来的空格怎么replace(" ","");不了? 问一个简单又不简单的问题。 怎么知道一段程序中,哪些语句占用cpu较多? java连数据库的问题 java中的static函数 关于JTable中JComboBox时间响应问题 关于字体显示 Set存值特点?
更多的数据库面试题,智力面试题,相声,笑话,请到:老紫竹的家
数据在电脑中是以二进制来存的,如果用a ++ 的话直接对a 的二进制的值的未位进行+1,不用再定义一个1,其他的好像都要再定义一个1
public class Test {
public static void main(String [] args) throws Exception{
int x=1;
x=x+1;
int y=1;
y+=1;
int z=1;
z++;
}
} public class Test
{ public Test()
{
// 0 0:aload_0
// 1 1:invokespecial #1 <Method void Object()>
// 2 4:return
} public static void main(String args[])
throws Exception
{
int i = 1;
// 0 0:iconst_1
// 1 1:istore_1
i++;
// 2 2:iload_1
// 3 3:iconst_1
// 4 4:iadd
// 5 5:istore_1
int j = 1;
// 6 6:iconst_1
// 7 7:istore_2
j++;
// 8 8:iinc 2 1
int k = 1;
// 9 11:iconst_1
// 10 12:istore_3
k++;
// 11 13:iinc 3 1
// 12 16:return
}
}比比谁的效率高。
Up
a++和++a再大型的程序设计里还是又区别
的,对整体的效率影响很大!