method overloading
import java.util.Scanner; class P14MethodOverloading { public static void main() { System.out.println("Enter two integer"); Scanner in = new Scanner(System.in); int start= in.nextInt(); int stop= in.nextInt(); while(stop> start) { int i= checkPrime(start);// This is called invoking or calling function. if( start==i) System.out.print(" "+start); start++; } checkPrime(); } static int checkPrime(int a) { int i=2; while(a>i) { if( a % i ==0) break; i++; } return i; } static void checkPrime() { System.out.println("\n\n\n\n This is the Example of method overloading."); System.out.println(" We are declaring two function with same name but different arguments "); } }
Comments
Post a Comment