# Some Rules to keep in mind while writing code:
### Syntax 1: Statements should end with a semicolon ;
Code :
```java
1. System.out.print(100)
```
Output :
```java
Error: ';' expected
System.out.print(100)
^
1 error
```
Explanation :
```
Line 1 gives error because ; is missing.
```
### Syntax 2: Java is case sensitive which can differentiate between lower and upper case.
Code :
``` java
1. system.out.print(5000);
```
Output :
```java
Error: package system does not exist
system.out.print(5000);
^
1 error
```
Explanation :
```plaintext
Line 1 gives error because S in System should be uppercase.
```
### Syntax 3: In order to print text we use double quotes.
Code1 :
```java
1. System.out.print(Rahul);
```
Output :
```java
Error: cannot find symbol
System.out.print(Rahul);
^
symbol: variable Rahul
```
Explanation :
```
Code will give error because " " are missing.
```
Code2 :
```java
1. System.out.print(“Rahul);
```
Output :
```java
Error: unclosed string literal
System.out.print("Rahul);
^
```
Explanation :
```
This will give error because opening quote is present before Rahul but closing quote (") is missing after Rahul.
```
### Syntax 4: () , {}, “ ” → These should be in pairs
Code1 :
```java
1. System.out.print("Rahul"};
```
Output :
```java
Error: ')' expected
System.out.print("Rahul"};
^
1 error
```
Explanation :
```
This will give an error because we have to use same type of brackets on both sides.
```
Code2 :
```java
1. System.out.print(Rahul;
```
Output :
```java
Error: ')' expected
System.out.print(Rahul;
^
1 error
```
Explanation :
```
This will give an error because we use brackets in pairs.
```
### Syntax 5: Comments
Compiler will ignore the statements which are written as comments
1. **Single Line comment**
> // Single Line Comment
Code1 :
```java
1. // System.out.println(“Super”);
2. System.out.println(“Excited”);
```
Output:
```java
Excited
```
Explanation :
```plaintext
Line 1 statement is a comment. So, Super is not getting printed.
```
2. **Multi Line comment**
>/*
This is a
multi - line
comment
*/
Code2 :
```java
1. System.out.println("Good Morning");
2. /* System.out.println(“Super”);
3. System.out.println(“Excited”);
4. */
5. System.out.println("Hello");
```
Output:
```java
Good Morning
Hello
```
Explanation :
```
Line 2, 3 and 4 are a part of multi line comment. So, Super and Excited are not getting printed in the output.
```
### Syntax 6: print() vs println()
Code1 :
```java
1. System.out.print(“Hello Guys!!”);
2. System.out.print(“My name is Rahul.”);
```
Output :
```java
Hello Guys!!My name is Rahul.
```
Code2 :
```java
1. System.out.println(“Hello Guys!!”);
2. System.out.print(“My name is Rahul.”);
```
Output :
```java
Hello Guys!!
My name is Rahul.
```
Explanation :
```
> System.out.print → Prints the output and cursor remains in same line.
> System.out.println → Prints the output and cursor goes to the next line.
```