Introduction
This blog based on Java Program, without main (). Java is a 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 the location where your program has save as like suppose desktop then type cd desktop then you see CMD
Then my program file save in a new folder 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 compiles successfully no any error.
After that run, the java program uses command java and class name …as like this.
Java math
Seen CMD for output.
Finally, no any error compiles and run time … the only exception after rum and output but before not any exception…