Java示例使用Method打印数组 Java示例方法覆盖 Java示例使用Break语句 Java示例使用Method打印数组 import java.util.ArrayList; import java.util.Vector; public class Main { public static void main(String[] args) { Object testObject = new ArrayList(); displayObjectClass(testObject); } public static void displayObjectClass(Object o) { if (o instanceof Vector) System.out.println( "Object was an instance of the class java.util.Vector"); else if (o instanceof ArrayList) System.out.println( "Object was an instance of the class java.util.ArrayList"); else System.out.println("Object was an instance of the " + o.getClass()); } } Java示例方法覆盖 Java示例使用Break语句