Create a Java program to demonstrate a method with varargs that prints the type and value of different arguments
public class ArgumentPrinter { static void printArgs(Object... args) { for (Object arg : args) { System.out.println("Type : " + arg.getClass().getSimpleName() + ", Value : " + arg); } } public static void main(String[] args) { printArgs(7, "Java", 23.14, true); } }
Type : Integer, Value : 7 Type : String, Value : Java Type : Double, Value : 23.14 Type : Boolean, Value : true
Learn All in Tamil © Designed & Developed By Tutor Joes | Privacy Policy | Terms & Conditions