List of usage examples for java.lang Object getClass
@HotSpotIntrinsicCandidate public final native Class<?> getClass();
From source file:Main.java
public static void main(String[] argv) throws Exception { Object o = new int[1][2][3]; o.getClass().getComponentType(); }
From source file:Main.java
public static void main(String[] argv) throws Exception { Object o = new String(); Class sup = o.getClass().getSuperclass(); // java.lang.Object }
From source file:Main.java
public static void main(String[] argv) throws Exception { Object o = new Object(); Class sup = o.getClass().getSuperclass(); // null }
From source file:Main.java
public static void main(String args[]) throws Exception { URL u = new URL("http://www.java2s.com"); Object o = u.getContent(); System.out.println(o.getClass().getName()); }
From source file:Main.java
public static void main(String[] args) { Object o = new String("Hello"); Class clazz = o.getClass().getSuperclass(); System.out.println("Super Class = " + clazz); o = new StringIndexOutOfBoundsException("Error message"); clazz = o.getClass().getSuperclass(); System.out.println("Super Class = " + clazz); }
From source file:Main.java
public static void main(String[] argv) throws Exception { Object object = new String(); // By way of an object Class cls = object.getClass(); }
From source file:MainClass.java
public static void main(String[] args) { try {//from w w w .ja v a2s . co m URL u = new URL("http://www.java2s.com"); Object o = u.getContent(); System.out.println("I got a " + o.getClass().getName()); } catch (Exception ex) { System.err.println(ex); } }
From source file:MainClass.java
public static void main(String args[]) { Object array = Array.newInstance(int.class, 3); Class type = array.getClass(); if (type.isArray()) { Class elementType = type.getComponentType(); System.out.println("Array of: " + elementType); System.out.println("Array size: " + Array.getLength(array)); }/* www . j a va 2 s . c om*/ }
From source file:Main.java
public static void main(String[] args) throws Exception { ScriptEngineManager manager = new ScriptEngineManager(); ScriptEngine engine = manager.getEngineByName("JavaScript"); String script = "var year = 2015"; engine.eval(script);/*from www. j av a2s . com*/ Object year = engine.get("year"); System.out.println("year's class:" + year.getClass().getName()); System.out.println("year's value:" + year); }
From source file:Main.java
public static void main(String[] args) { String str = "This is from java2s.com"; Class cls = str.getClass();/*from www .j a v a2 s.c o m*/ boolean arr = cls.isArray(); System.out.println(arr); Object array = Array.newInstance(int.class, 3); Class type = array.getClass(); if (type.isArray()) { Class elementType = type.getComponentType(); System.out.println("Array of: " + elementType); System.out.println("Array size: " + Array.getLength(array)); } }