Last active
August 29, 2015 13:56
-
-
Save LNA/8959682 to your computer and use it in GitHub Desktop.
Java Basics
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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