This blog based on Java Program, without main (). Java is class based object oriented programming Language.
Example
- class Math
- {
- Static
- {
- int a, b, c;
- a=12;
- b=5;
- c=a+b;
- if(c==a+b)
- {
- System.out.println("a+b\t" +c );
- c=a-b;
- if(c==a-b)
- {
- System.out.println("a-b\t" +c);
- c=a*b;
- if(c==a*b)
- {
- System.out.println("a*b\t" +c);
- c=a/b;
- if(c==a/b)
- {
- System.out.println("a/b\t" +c);
- }
- else
- {
- System.out.println("No result");
- }
- }
Create this program in notepad and open CMD and got to location where your program have save as like suppose desktop then type cd desktop then you see CMD
Then my program file save in new folder as like java prog so then I command use cd java prog then seen CMD
Then seen output use command for compile java program.
Javac math.java
When compile program then automatically generate class file go to java prog folder or own location where you save math.java program.
It is compile successfully no any error.
After that run the java program use command java and class name …as like this.
Java math
Seen CMD for output.
Finally no any error compiles and run time … only exception at after rum and output but before not any exception…