Java Program without main () Function

This blog based on Java Program, without main ().

Introduction 

 
This blog based on Java Program, without main (). Java is a class-based object-oriented programming language.
  
Example
  1. class Math {  
  2.  Static {  
  3.   int a, b, c;  
  4.   a = 12;  
  5.   b = 5;  
  6.   c = a + b;  
  7.   if (c == a + b) {  
  8.    System.out.println("a+b\t" + c);  
  9.    c = a - b;  
  10.    if (c == a - b) {  
  11.     System.out.println("a-b\t" + c);  
  12.     c = a * b;  
  13.     if (c == a * b) {  
  14.      System.out.println("a*b\t" + c);  
  15.      c = a / b;  
  16.      if (c == a / b) {  
  17.       System.out.println("a/b\t" + c);  
  18.      } else {  
  19.       System.out.println("No result");  
  20.      }  
  21.     }  
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
 
z
 
Then my program file save in a new folder like java prog so then I command use cd java prog then seen CMD.

x
 
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.
 
c
 
Finally, no any error compiles and run time … the only exception after rum and output but before not any exception…