September 2016
Beginner to intermediate
1089 pages
23h 8m
English
So what exactly is a class? A class is a bunch of code that can contain methods, variables, loops, and all other types of Java syntax. A class is part of a package and most packages will normally have multiple classes. Usually, but not always, each new class will be defined in its own .java code file with the same name as the class.
Once we have written a class, we can use it to make as many objects from it as we need. Remember, the class is the blueprint, and we make objects based on the blueprint. The house isn't the blueprint just as the object isn't the class; it is an object made from the class.
Here is the code for a class. We call it a class implementation:
public class Soldier { int health; String soldierType; ...Read now
Unlock full access