Java Program to Use Method Overloading for Printing Different Types of Array Last Updated : 23 Jul, 2025 Comments Improve Suggest changes Like Article Like Report In Java method overloading can be defined as the class containing multiple methods with the same name but the list of parameters or type of parameters or the order of the parameters of the methods should not be the same. We can print different types of arrays using method overloading in java by making sure that the method contains different parameters with the same name of the method. Let's implement a program with the printArray() method overloaded three times to print different types of array. And every time the function has different parameters. In the main method provide the required inputs to each array and then by calling their respective methods the array printed on the screen. Implementation: Java // Java Program to Use Method Overloading // for Printing Different Types of Array class methodOverloadingDemo { // creating a method for printing integer // array with integer parameter public static void printArray(Integer[] arr) { System.out.println("The Integer array is: "); // for loop for printing the elements of array for (Integer i : arr) System.out.print(i + " "); System.out.println(); } // overloading the above created method with different // parameter method contains a character parameter public static void printArray(Character[] arr) { System.out.println("\nThe Character array is: "); // for loop for printing the elements of array for (Character i : arr) System.out.print(i + " "); System.out.println(); } // now the parameter for the overloaded method is String public static void printArray(String[] arr) { System.out.println("\nThe String array is: "); // for loop for printing the elements of array for (String i : arr) System.out.print(i + " "); System.out.println(); } // now the parameter for the overloaded method is double public static void printArray(Double[] arr) { System.out.println("\nThe Double array is: "); // for loop for printing the elements of array for (Double i : arr) System.out.print(i + " "); } // main function public static void main(String args[]) { // calling the parameters of all the // methods and taking the inputs Integer[] iarr = { 2, 4, 6, 6, 8 }; Character[] carr = { 'H', 'E', 'L', 'L', 'O' }; String[] sarr = { "Ram", "Nidhi", "John", "Raju", "Sara" }; Double[] darr = { 10.0123, 89.123, 65.132, 78.321, 1.798 }; // calling the methods and printing the arrays printArray(iarr); printArray(carr); printArray(sarr); printArray(darr); } } OutputThe Integer array is: 2 4 6 6 8 The Character array is: H E L L O The String array is: Ram Nidhi John Raju Sara The Double array is: 10.0123 89.123 65.132 78.321 1.798 Time Complexity: O(N), where N is the size of the array. Auxiliary space: O(1) because constant variables have been used Create Quiz Comment N neelutiwari Follow 0 Improve N neelutiwari Follow 0 Improve Article Tags : Java Technical Scripter Java Programs Technical Scripter 2020 Java-Array-Programs +1 More Explore Java BasicsIntroduction to Java3 min readJava Programming Basics9 min readJava Methods6 min readAccess Modifiers in Java4 min readArrays in Java7 min readJava Strings7 min readRegular Expressions in Java3 min readOOP & InterfacesClasses and Objects in Java5 min readAccess Modifiers in Java4 min readJava Constructors4 min readJava OOP(Object Oriented Programming) Concepts10 min readJava Packages2 min readJava Interface7 min readCollectionsCollections in Java12 min readCollections Class in Java13 min readCollection Interface in Java4 min readIterator in Java4 min readJava Comparator Interface5 min readException HandlingJava Exception Handling6 min readJava Try Catch Block4 min readJava final, finally and finalize4 min readChained Exceptions in Java3 min readNull Pointer Exception in Java5 min readException Handling with Method Overriding in Java4 min readJava AdvancedJava Multithreading Tutorial3 min readSynchronization in Java7 min readFile Handling in Java4 min readJava Method References7 min readJava 8 Stream Tutorial7 min readJava Networking6 min readJDBC Tutorial5 min readJava Memory Management3 min readGarbage Collection in Java6 min readMemory Leaks in Java3 min readPractice JavaJava Interview Questions and Answers1 min readJava Programs - Java Programming Examples7 min readJava Exercises - Basic to Advanced Java Practice Programs with Solutions5 min readJava Quiz1 min readJava Project Ideas For Beginners and Advanced15+ min read Like