Skip to content

Instantly share code, notes, and snippets.

@LNA
Last active August 29, 2015 13:56
Show Gist options
  • Save LNA/8959682 to your computer and use it in GitHub Desktop.
Save LNA/8959682 to your computer and use it in GitHub Desktop.
Java Basics
// What is an instance variable?
// An instance variable is the variable declared inside of the class but outside of the method.
class Shoe {
// these are all instance variables:
public String shoeBrand;
public String[] shoeSeason;
public int shoeSize;
// getters and setters follow
}
class Wardrobe {
// Wardrobe is main. I can stick multiple instances of the Shoe class here.
public static void main(String[] a){
Shoe mykicks = new Shoes();
mykicks.shoeBrand = "Nike";
mykicks.season = "Spring";
mykicks.shoeSize(8);
Shoe myboots = new Shoes();
myboots.shoeBrand = "Ralph Lauren";
myboots.season = "Winter";
myboots.shoeSize(8.5);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment