We have made the method to calculate area. We call this method from main method and then enter the radius of the circle as input. Now we calculate area and print the output.
Here is the source code of the Java Program to Illustrate a Method without Parameters and Without Return Type. The Java program is successfully compiled and run on a Windows system. The program output is also shown below.
public class Test
System.out.print("enter the radius :");
Scanner s = new Scanner(System.in);
float r = s.nextFloat();
ar = (r * r) * 22 / 7;
System.out.println("area of the circle is : "+ar+" sq units.");
public static void main(String args)
Test obj = new Test();
$ javac Method_Demo.java $ java Method_Demo enter the radius :3 area of the circle is:28.285715 sq units.
Sanfoundry Global Education & Learning Series – 1000 Java Programs.