Instance Variables

Instance Variables

Instance variables belong to the instance of a class or object and are declared within in a class, but outside a method. Every instance of a class with an instance variable will have its own copy of that instance variable.

As instance variables are independent, if you make any changes to a variable those changes are not reflected in other instances of that class.

public class Name{
    public String myName;

Leave a Reply

%d bloggers like this: