Packages allow grouping of related types (classes, interfaces, etc) while providing access protection and namespace management. The package declaration must be the first statement at the top of every source file that contains the types that you want to include in the package. The recommended naming convention is: All lower case ..Continue Reading
Basically, a class can have fields, constructors, methods and nested types. The following pseudocode shows the skeleton of a Java class:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
[Modifiers] class ClassName [extends OnlyOneSuperClass] [implements InterfaceList] { // fields [Modifiers] type variableName; // constructors [Modifiers] ClassName([ParameterList]) [ExceptionList] {…} // methods [Modifiers] returnType methodName([ParamList]) [ExceptionList] {…} // nested types [Modifiers] (class|interface|enum) NestedTypeName {…} } |
[ ] = optional, | = or You will learn about modifiers, constructors, methods and nested types later in the topic 6 lessons. For now, knowing that a Java class ..Continue Reading
You probably know everything about variables, but there are three things you need to grasp well for the Java SE Programmer exams: Kinds of variables Default values Naming Kind Also known as Description Default values Instance variables Non-static fields Fields declared without static. They store individual states of objects. Yes ..Continue Reading