About 233,000 results
Open links in new tab
  1. What is the difference between local and instance variables in Java ...

    Jan 18, 2010 · Except the scope and the storage differences, are there any other major difference between instance and local variables in Java?

  2. Why must local variables, including primitives, always be initialized ...

    Oct 13, 2009 · Why must local variables, including primitives, always be initialized in Java? Why is the same not applicable in the case of instance variables?

  3. java - Difference between final and effectively final - Stack Overflow

    Jan 6, 2014 · I'm playing with lambdas in Java 8 and I came across warning local variables referenced from a lambda expression must be final or effectively final. I know that when I use variables inside …

  4. Why would one mark local variables and method parameters as "final" …

    Nov 21, 2011 · Making local variables and method parameters final is essential if you want to pass those parameters into anonymous classes - like you instantiate an anonymous Thread and want to access …

  5. Why are local variables not initialized in Java? - Stack Overflow

    Before Java 7, instance variables are stored on the heap and local variables are found on the stack. However, any object that a local variable references will be found in the heap.

  6. How do I create a static local variable in Java? - Stack Overflow

    Jan 17, 2010 · Although Java doesn't support static local variables, it's fairly easy to emulate in recent versions of Java. From Java 16 onwards, it is possible to create a local class with a mutable static …

  7. java - Variable used in lambda expression should be final or ...

    Jan 19, 2016 · Java 8 realized the pain of declaring local variable final every time a developer used lambda, introduced this concept, and made it unnecessary to make local variables final.

  8. Use of final local variables in java - Stack Overflow

    Aug 14, 2013 · For classes and methods, it's about inheritance; for variables it's about being read-only. There's one important "feature" of final local variables: they can be used in local (typically …

  9. java - Modifying local variable from inside lambda - Stack Overflow

    May 4, 2015 · Modifying a local variable in forEach gives a compile error: Normal int ordinal = 0; for (Example s : list) { s.setOrdinal(ordinal); ordinal++; } With Lambda int

  10. Why Java initializing only class variables by default but not local ...

    Oct 27, 2014 · Field variables are initialized by default. This is because those variables need to be accessable as soon as the instance is created, since they are accessable as long as the object is …