-
Notifications
You must be signed in to change notification settings - Fork 0
/
00. Intro.txt
65 lines (44 loc) · 3.11 KB
/
00. Intro.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
Every java program should have at least main function. This is entry point for programs.
A class is a container of related functions.
First letter of every word should be uppercase in the name of class.
A method is a function that is part of a class. If it exists outside of class, it is called function.
Access Modifier: public, private and so on.
-----------------------------------------------------------------------------------------------------------------
Under the hood:
Compilation: from java code to byte code(.class)
Java Virtual Machine translates bytecode into native code for the OS.
In terminal:
javac Main.java
java com.tahseen.Main
-----------------------------------------------------------------------------------------------------------------
James Gosling in 1995 at Sun Microsystems.
It was originally called Oak.
-----------------------------------------------------------------------------------------------------------------
- class keyword is used to declare a class in Java.
- public keyword is an access modifier that represents visibility. It means it is visible to all.
- static is a keyword. If we declare any method as static, it is known as the static method. The core advantage of the static method is that there is no need to create an object to invoke the static method. The main() method is executed by the JVM, so it doesn't require creating an object to invoke the main() method. So, it saves memory.
- void is the return type of the method. It means it doesn't return any value.
- main represents the starting point of the program.
- String[] args or String args[] is used for command line argument. We will discuss it in coming section.
- System.out.println() is used to print statement. Here, System is a class, out is an object of the PrintStream class, println() is a method of the PrintStream class. We will discuss the internal working of System.out.println() statement in the coming section.
-----------------------------------------------------------------------------------------------------------------
Difference between JDK, JRE and JVM:
All these are platform dependent, however JAVA is platform independent.
JVM:
JVM is an abstract machine. It provides runtime environment in which bytecode can be executed. It performs following main tasks -
- loads code
- verifies code
- executes code
- provides runtime environment
JRE:
Used for developing java applications. It is the implementation of JVM. It contains set of libraries + other files that JVM uses
at runtime.
JDK:
Used to develop java applications. JRE + development tool. It is the implementation of any of the below platforms -
- Standard edition
- Enterprise edition
- Micro edition
-----------------------------------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------------------------------