I keep getting this error: "cannot resolve symbol - constructor MyFileStructure()". I do have a class with that name, and in fact, the first time I tried to compile the code below, BlueJ even drew the arrow to the class. So why then can it not friggin see it? I even copy and pasted to make sure I had no dumb spelling mistakes in the class name.
Code:
public static void main(String[] args)
{
if(args.length != 0)
{
MyFileStructure mf = new MyFileStructure();
mf.setDirName(args[0]);
mf.build();
mf.list();
}
}
03-08-2004, 02:10 PM
cjard
can you post more of the code?
you ahvent done soemthing daft like this have you?:
Code:
public class MyFileStructure{
public void MyFileStructure(){
...
thats a method with the same name as the clas, not a coinstructor.. constructors have no return type:
public MyFileStructure(){
03-08-2004, 02:38 PM
Phaelax
Nope, didn't do that.
Code:
public class MyFileStructure
{
private String dirName; //name of top directory
private MyDir mdir; //name of top MyDir(holding complete directory structure)
public MyFileStructure(String dirName)
{
dirName = dirName;
}
}
I thought that a constructor that took no parameters was valid, whether I put one in or not. I just added a no argument constructor, and my test class compiled ok. Still can't run it, cause something is wrong with the machine. Keeps locking up when I try to run. I hate school computers.
03-08-2004, 03:49 PM
mikeBarr81
if you don't specify any constructor at all i believe a default one is added for you when you compile it, but if you specify a constructor that takes parameters then no default constructor is added. You need to add one yourself (like you did).
03-10-2004, 02:34 PM
cjard
i.e. the EMPTY constructor is only available when a class contains ZERO other constructors. modify your code:
Code:
public class MyFileStructure
{
private String dirName; //name of top directory
private MyDir mdir; //name of top MyDir(holding complete directory structure)
public MyFileStructure(){}
public MyFileStructure(String dirName)
{
dirName = dirName;
}
}