Error at Compilation
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Marcos_Luque
Posted On:   Tuesday, January 3, 2006 07:56 PM

i'm declaring a Class object like this:

Class type[]= {java/lang/String, java/lang/Float};


and when i compile, the BlueJ enlight all the line and sends me an error that says :

"Cannot find Symbol"

how it suppoused to be declared this type of variables???

Help please!!! thanks Sincerily

Re: Error at Compilation

Posted By:   Anonymous  
Posted On:   Wednesday, January 18, 2006 11:35 AM

Your array of Class objects should be instantiated like this (I have put in a class to illustrate it):



public class ClassCode {

Class type[]=null;

public ClassCode() {

try {
type[0] = Class.forName("java/lang/String");
type[1] = Class.forName("java/lang/Float");
}
catch (ClassNotFoundException ex) {
ex.printStackTrace();
}

}
}


Quote from the javadoc: Class has no public constructor. Instead Class objects are constructed automatically by the Java Virtual Machine as classes are loaded and by calls to the defineClass method in the class loader.
About | Sitemap | Contact