What is the difference between local and instance variables in Java?

One extra thing I can think of:

Instance variables are given default values, i.e., null if it’s an object reference, and 0 if it’s an int.

Local variables don’t get default values, and therefore need to be explicitly initialized (and the compiler usually complains if you fail to do this).

Leave a Comment