我用Java创建了一个小应用程序,因为我不是java专家所以我的程序效率不高(效率我的意思是更少的执行时间,即我想要更快的结果).如果有经验的人会回答我的以下问题,我将感激不尽:
哪一个更快:
问题1
boolean b1;
b1=true;
Run Code Online (Sandbox Code Playgroud)
要么
boolean b1= true;
Run Code Online (Sandbox Code Playgroud)
问题2
boolean b1;
boolean b2;
Run Code Online (Sandbox Code Playgroud)
要么
boolean b1, b2;
Run Code Online (Sandbox Code Playgroud)
问题3
for (int index goes to some iterations)
{
MyCustomClass obj = new MyCustomClass ();
//Some other code goes here
}
Run Code Online (Sandbox Code Playgroud)
要么
MyCustomClass obj = new MyCustomClass ();
for (int index goes to some iterations)
{
obj.Reset();// Assume .Reset() have same codes as zero argument constructor has
//Some other code goes here
}
Run Code Online (Sandbox Code Playgroud)
提前致谢