Skip to main content

Command Palette

Search for a command to run...

JAVA : Right way to find the list size in loop to save memory ?

Updated
1 min read
JAVA : Right way to find the list size in loop to save memory ?
S

I love learning about technology and sharing that with others

better way to find the list size once and limiting the scope of variables.

  for( int i=0 , n=test.size();i<n;i++) {
            System.out.println(test.get(i));
        }

After 1.5 java we can use for each

  for(int a : test) {
            System.out.println(a);
        }
9 views

More from this blog

H

hashcodehub

271 posts

Consistent, Passionate and Organized :)