Skip to content

Commit 045b9db

Browse files
Basic Structure Of Java Program
1 parent df3a8e4 commit 045b9db

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# Basic Structure of a Java Program: Understanding our First Java Hello World Program
2+
3+
## Basic Structure of a Java Program
4+
5+
```
6+
package com.company; // Groups classes
7+
public class Main{ // Entrypoint into the application
8+
public static void main(String[]args){
9+
System.out.println(“Hello World”);
10+
}
11+
}
12+
```
13+
14+
## Working of the "Hello World" program shown above :
15+
16+
### 1. package com.company :
17+
- Packages are used to group the related classes.
18+
- The "Package" keyword is used to create packages in Java.
19+
- Here, com.company is the name of our package.
20+
21+
### 2. public class Main :
22+
- In Java, every program must contain a class.
23+
- The filename and name of the class should be the same.
24+
- Here, we've created a class named "Main".
25+
- It is the entry point to the application.
26+
27+
### 3. public static void main(String[]args){..} :
28+
- This is the main() method of our Java program.
29+
- Every Java program must contain the main() method.
30+
31+
### 4. System.out.println("Hello World"):
32+
- The above code is used to display the output on the screen.
33+
- Anything passed inside the inverted commas is printed on the screen as plain text.
34+
35+
### 5. Naming Conventions
36+
- For classes, we use Pascal Convention. The first and Subsequent characters from a word are capital letters (uppercase).
37+
- Example: Main, MyScanner, MyEmployee, CodeWithHarry
38+
- For functions and variables, we use camelCaseConvention. Here the first character is lowercase, and the subsequent characters are uppercase like myScanner, myMarks, CodeWithHarry
39+
40+
### Handwritten Notes: [Click To Download](https://api.codewithharry.com/media/videoSeriesFiles/courseFiles/java-tutorials-for-beginners-2/IntroToJava.pdf)
41+
42+
### Ultimate Java Cheatsheet: [Click To Download](https://api.codewithharry.com/media/videoSeriesFiles/courseFiles/java-tutorials-for-beginners-2/UltimateJavaCheatSheet.pdf)

0 commit comments

Comments
 (0)