- Every line of code in Java must be inside a
class
- A class should always start with an uppercase letter
- Java is case-sensitive
- The name of Java file must match the class name
- Save the file with
.java
in the end
Main
-
The main is required :
public static void main(String args[])
-
Every program contains a main
System.out.println()
- Used inside the main method
public static void main(String[] args){
System.out.println("Hello World");
}
[!Note]
The curly braces
{}
marks the beginning of and end block of the codeSystem is a built-in Java class containing members like out for ‘output’
The println() known as print-line
Each code should end with a semi-colon
;
println()
- Used to output or print text
- When using text we should use double-quotes
""
-
Adds a new-line after every output making it more systematic to read
- System.out.println(“Say it..”)
- ==System.out.println(This will produce an error !)
print()
- Here it does not insert a new-line after every output
System.out.print("Hello");