List of usage examples for java.lang Class getName
public String getName()
From source file:Main.java
public static void main(String[] args) { // Get the name of the classes below. Class clazz = String.class; System.out.println("Class Name: " + clazz.getName()); clazz = Calendar.class; System.out.println("Class Name: " + clazz.getName()); clazz = BigDecimal.class; System.out.println("Class Name: " + clazz.getName()); }
From source file:Main.java
public static void main(String[] args) { Main c = new Main(); Class cls = c.getClass(); // returns the name of the class String name = cls.getName(); System.out.println("Class Name = " + name); // returns the simple name of the class String sname = cls.getSimpleName(); System.out.println("Class SimpleName = " + sname); }
From source file:Main.java
public static void main(String[] args) { Main cl = new Main(); Class c1Class = cl.getClass(); // returns the name of the class String name = c1Class.getName(); System.out.println(name);// w ww . j a v a2 s .c o m }
From source file:Main.java
public static void main(String[] args) { Main c = new Main(); Class cls = c.getClass(); // returns the name of the class String name = cls.getName(); System.out.println("Class Name = " + name); // returns assertion status boolean retval = cls.desiredAssertionStatus(); System.out.println("status = " + retval); }
From source file:Main.java
public static void main(String[] args) { Main c = new Main(); Class cls = c.getClass(); // returns the name of the class String name = cls.getName(); System.out.println("Class Name = " + name); // returns true if this class is an anonymous class boolean retval = cls.isAnonymousClass(); System.out.println(retval);//w w w . jav a2 s . com }
From source file:Main.java
public static void main(String[] args) throws Exception { Class clazz = String.class; Constructor[] constructors = clazz.getDeclaredConstructors(); for (Constructor constructor : constructors) { String name = constructor.getName(); System.out.println("Constructor name= " + name); Class[] paramterTypes = constructor.getParameterTypes(); for (Class c : paramterTypes) { System.out.println("Param type name = " + c.getName()); }/*w w w . j av a 2 s . co m*/ } Constructor constructor = String.class.getConstructor(new Class[] { String.class }); System.out.println("Constructor = " + constructor.getName()); }
From source file:Main.java
public static void main(String[] args) throws Exception { Recording recording = new Recording(); recording.setTitle("Magical Mystery Tour"); Class type = PropertyUtils.getPropertyType(recording, "title"); System.out.println("type = " + type.getName()); String value = (String) PropertyUtils.getProperty(recording, "title"); System.out.println("value = " + value); }
From source file:GetMethods.java
public static void main(String[] args) throws Exception { GetMethods object = new GetMethods(); Class clazz = object.getClass(); Method[] methods = clazz.getMethods(); for (Method method : methods) { System.out.println("Method name = " + method.getName()); System.out.println("Method return type = " + method.getReturnType().getName()); Class[] paramTypes = method.getParameterTypes(); for (Class c : paramTypes) { System.out.println("Param type = " + c.getName()); }//from w ww .j a v a 2s . c o m } Method method = clazz.getMethod("add", new Class[] { int.class, int.class }); System.out.println("Method name: " + method.getName()); }
From source file:Main.java
public static void main(String[] args) throws Exception { Class cls = Class.forName("Main"); // returns the name of the class System.out.println("Class = " + cls.getName()); // returns the ProtectionDomain of this class. ProtectionDomain p = cls.getProtectionDomain(); System.out.println(p);/*from ww w . j a v a 2 s . c om*/ }
From source file:Main.java
public static void main(String[] args) throws Exception { File f = new File("c:/mysql-connector-java-5.1.18-bin.jar"); URLClassLoader urlCl = new URLClassLoader(new URL[] { f.toURL() }, System.class.getClassLoader()); Class mySqlDriver = urlCl.loadClass("com.mysql.jdbc.Driver"); System.out.println(mySqlDriver.newInstance()); System.out.println("Is this interface? = " + mySqlDriver.isInterface()); Class interfaces[] = mySqlDriver.getInterfaces(); int i = 1;//w w w . j av a2 s. c o m for (Class _interface : interfaces) { System.out.println("Implemented Interface Name " + (i++) + " = " + _interface.getName()); } Constructor constructors[] = mySqlDriver.getConstructors(); for (Constructor constructor : constructors) { System.out.println("Constructor Name = " + constructor.getName()); System.out.println("Is Constructor Accessible? = " + constructor.isAccessible()); } }