CS202 Java-5
Classes in Java
lEverything we do in Java is part of a class
•This means that none of our functions can be “global” like they can be in C or C++
lClasses in Java specify types, as they do in C++ and allow us to create abstractions
•Classes must be specified as public, or not.
•Only public classes are available for the outside world to create objects of
•If the keyword public doesn’t precede a class, then it is “friendly” and only classes from within this file or package (a group of files) can create objects Every package (or file to begin with) has a public class
lInside of a class, Java supports public, protected, and private access (or nothing – which means “friendly” access)
•But unlike C++, it requires that they be specified in front of each member rather than specifying categories!
•This means that everything has some kind of access specified for it.