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

    Jan 18, 2010 · Existence time: Local variables are created when a method is called and destroyed when the method exits whereas instance variables are created using new and destroyed by the garbage …

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

    Oct 13, 2009 · 11 In Java, class and instance variables assume a default value (null, 0, false) if they are not initialized manually. However, local variables don't have a default value. Unless a local variable …

  3. 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 …

  4. Variable default value in Java - Stack Overflow

    9 From the Java Language Specification, Java SE 8 Edition, 4.12.5 Initial Values of Variables: A local variable (§14.4, §14.14) must be explicitly given a value before it is used, by either initialization …

  5. Java instance variables vs. local variables - Stack Overflow

    4 Local variables internal to methods are always prefered, since you want to keep each variable's scope as small as possible. But if more than one method needs to access a variable, then it's going to have …

  6. java - What is the difference between a local variable, an instance ...

    Dec 18, 2013 · What is the difference between a local variable, an instance field, an input parameter, and a class field with respect to a simple Java program?

  7. 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 …

  8. Local variables or member variables in Java - Stack Overflow

    Apr 29, 2013 · 2 I have a question about local and member variables in Java. The situation is: Sometimes if I define a local variable, that variable has to be passed around into several levels of …

  9. What happen when a method returns a local variable in java? Does the ...

    May 29, 2021 · Local variables' lifetime does NOT extend after the method has returned. Java methods are not closures. BUT: the objects created within a method have a completely different lifetime. The …

  10. Java error "Value of local variable is not used" - Stack Overflow

    Jun 16, 2012 · 1) "value of local variable p is not used" is a compile time warning. 2) A Launch Error is a run-time error rather than a compile time error. 3) Someone who is "really new to java" should try …