Efficiency of Java code with primitive types

Posted by super89 on Stack Overflow See other posts from Stack Overflow or by super89
Published on 2010-05-07T10:14:51Z Indexed on 2010/05/07 10:18 UTC
Read the original article Hit count: 301

Filed under:
|
|
|

Hello! I want to ask which piece of code is more efficient in Java? Code 1:

void f()
{
 for(int i = 0 ; i < 99999;i++)
 {
  for(int j = 0 ; j < 99999;j++)
  {
   //Some operations
  }
 }

}

Code 2:

void f()
{
 int i,j;
 for(i = 0 ; i < 99999;i++)
 {
  for(j = 0 ; j < 99999;j++)
  {
   //Some operations
  }
 }

}

My teacher said that second is better, but I can't agree that opinion.

© Stack Overflow or respective owner

Related posts about java

Related posts about jvm