Skip to main content

Creating First java program

Step to create and run first java program

  • Write java code in Notepad
  • Save file as .java extension
  • Compile java program
  • Run Java program

 

Step 1: Write java code in notepad and save as class name.java

(Class name should be same as file name)

 

n1

 

Step 2: Go to the path where you saved your java file

n2

Step 3: Compiling java program

n3

 
When you compile java program it generates .class file
class

Step 3: Run java program

n4

See Java Program which Print integer,float,double and String Value
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
 
package basic;
 
public class Sample {
 
	public static void main(String[] args)
	{
 
	System.out.println("hii this is bhavesh lakhani");	
 
	System.out.println("i love \"java\" programing ");
 
	System.out.println(0101);//65 because it is octal number
 
	System.out.println(010);// 8 because it is octal number
 
	System.out.println("**************************************");
 
	//you can print value of integer, double, float, character, string and 
	//boolean value
	System.out.println(1234);
	System.out.println(2.444);
	System.out.println(2.3f);
	System.out.println('B');
	System.out.println(true);
 
 
	}
 
}
 
output:
 
hii this is bhavesh lakhani
i love "java" programing 
65
8
**************************************
1234
2.444
2.3
B
true