Professional Documents
Culture Documents
Java Notes: - Package (Folder) : Is A Mechanism To Encapsulate A Group of Classes, Subpackages, and Interfaces
Java Notes: - Package (Folder) : Is A Mechanism To Encapsulate A Group of Classes, Subpackages, and Interfaces
- Java is case sensitive>>>> naming Classes start with uppercase first letter
- The class of the main method MUST have the same name of the file containing it.
- To print in java, use System.out. println(“”);
- In java, codes are written inside classes ONLY.
- Package (folder): is a mechanism to encapsulate a group of classes, subpackages, and interfaces.
- System.out.print(): prints the string and leaves the cursor at the end.
System.out.println(): prints the string and moves the cursor to a new line.
System.out.printf(): format.
Explanation:
System is a class in java.lang package. Inside the System class, out is a static instance of class
PrintStream in java.io package. Inside the PrintStream class, println() is a method
- Syntax for instantiating a struct variable: - Syntax for instantiating a struct variable:
struct structName instanceName structName instanceName
Note the use of struct keyword. - Syntax for instantiating an object of a class:
className instanceName
-
C/C++ vs Java
C/C++ Java
In C, “static” keyword is overloaded for two different Same as number three in C/C++
semantics:
1) for a global variable, makes it accessible only
inside the file in which it is declared.
2) for a local variable, makes it available through all
the program time, but visible inside its scope only
In C++, there is an additional third semantic:
3) makes data members and member methods
belonging to Class rather than an object.