Skip to main content
2 of 8
added 6 characters in body
Skylar Adams
  • 433
  • 2
  • 4
  • 6

what's the difference between class variables and instance variables in java?

I'm very new to java and I'm trying my best to uderstand it.One of the brick walls i've hit is the difference between class and instance variables. For example

class Bicycle {

int cadence = 0;

int speed = 0;

int gear = 1;

So is this a class or instance variable and how are the two different from each other. I'm also having trouble understanding how several istance variables can be different fronm each other and yet come from the same class variable. All help will be greatly appreciated

Skylar Adams
  • 433
  • 2
  • 4
  • 6