19 package examples.util;
21 import java.io.PrintStream;
22 import java.lang.reflect.Array;
23 import java.util.Collection;
37 public static void print(PrintStream ps, Object o)
43 else if (o.getClass().isArray())
46 if (o.getClass().getComponentType().isPrimitive())
48 int length = Array.getLength(o);
49 for (
int i = 0; i < length; i++)
51 Object obj = Array.get(o, i);
61 Object[] objects = (Object[]) o;
62 for (
int i = 0; i < objects.length; i++)
68 print(ps, objects[i]);
73 else if (o instanceof Collection)
76 Collection<?> array = (Collection<?>) o;
78 for (Object e : array)
92 else if (o instanceof Number)
94 Number n = (Number) o;
95 if (n.intValue() == n.floatValue())
97 ps.print(n.intValue());
101 ps.print(n.floatValue());
111 public static void println(PrintStream ps, Object o)