They both are *member* variables, meaning that both are associated with a class. Now of course, there are differences between the two:

**Instance variables:**

These variables belong to the *instance of a class*, thus an object. And every instance of that class (object) has it's own copy of that variable. Changes made to the variable don't reflect in other instances of that class.

    public class Product {
        public int Barcode;
    }

**Class variables:**

These are also known as *static member variables* and there's only one copy of that variable that is shared with all instances of that class. If changes are made to that variable, all other instances will see the effect of the changes.

    public class Product {
        public static int Barcode;
    }

**Full example:**

    // INSTANCE VARIABLE
    public class Main {

        public static void main(String[] args) {
        
            Product prod1 = new Product();
            prod1.Barcode = 123456;

            Product prod2 = new Product();
            prod2.Barcode = 987654;

            System.out.println(prod1.Barcode);
            System.out.println(prod2.Barcode);
        }
    }

    public class Product {
        public int Barcode;
    }

The output will be:

>    123456

>    987654

Now, change the instance variable to a class variable by making it static:

    //CLASS VARIABLE
    public class Main {

        public static void main(String[] args) {
        
            Product prod1 = new Product();
            Product.Barcode = 123456;

            Product prod2 = new Product();
            Product.Barcode = 987654;

            System.out.println(prod1.getBarcode());
            System.out.println(prod2.getBarcode());
        }
    }

    public class Product {
    
        public static int Barcode;

        public int getBarcode() {
            return Barcode;
        }
    }
I used a non-static method to get the value of `Barcode` to be able to call it from the object and not from the class. The output will be following:

> 987654

> 987654