Hello everyone, I hope this is rather simple, but I am getting a strange error in code. I have two classes, one calls the other to return a string. It is very simple code: public class returnList { public String[] returnList() { String lStr = "hello"; String [] lRetStr = new String[1]; lRetStr[0] = lStr; return lRetStr; } } AND //import java.sql.*; //import org.gjt.mm.mysql.*; public class test_db { public static void main(String[] Args) { returnList lList = new returnList(); String lStr[] = lList.returnList(); System.out.println(lStr[0]); } } When I - javac returnList.java it compiles just fine. When I - javac test_db.java I get: test_db.java:8:cannot resolve symbol symbol : class returnList Loction : class test_db returnList lList = new returnList(); ^ This code compiles just fine in Windows. I assume that I am missing a library or that I have not installed a package. Can anyone give me a hand with this? Thanks for your help, Jim
Le Mardi 13 Novembre 2001 22:49, James Bliss a écrit :
Hello everyone,
I hope this is rather simple, but I am getting a strange error in code. I have two classes, one calls the other to return a string. It is very simple code:
public class returnList { public String[] returnList() { String lStr = "hello"; String [] lRetStr = new String[1]; lRetStr[0] = lStr; return lRetStr; }
} I'm really surprised that this compiles under Windows. Your constructor (returnList()) shouldn't return anything. It should be: public returnList()
I bet you should create an empty constructor : public returnList(){} and put you code inside a method: public String[] getList() { String lStr = "hello"; String [] lRetStr = new String[1]; lRetStr[0] = lStr; return lRetStr; }
AND
//import java.sql.*; //import org.gjt.mm.mysql.*;
public class test_db { public static void main(String[] Args) { returnList lList = new returnList(); String lStr[] = lList.returnList(); System.out.println(lStr[0]); } }
I think this is fine, altough I'm not used to work with arrays.
When I - javac returnList.java it compiles just fine.
When I - javac test_db.java
I get: test_db.java:8:cannot resolve symbol symbol : class returnList Loction : class test_db returnList lList = new returnList(); ^
This code compiles just fine in Windows. I assume that I am missing a library or that I have not installed a package.
Can anyone give me a hand with this?
Thanks for your help,
Jim
participants (2)
-
David Garnier
-
James Bliss