THE KID
THE KID

Reputation: 47

cannot find symbol using Test File

I'm trying to test my createMTree method. The method works fine and I can compile and run it using tests in a main method inside of the class file MTreeNode. However trying to call the method in my test file test.java gives me a cannot find symbol error. I can test other methods from MTreeNode in test.java just fine.

test.java:

public class test{

 public static void main(String[] args) {

  MTreeNode<String> myRoot = MTreeNode.createMTree("input.txt");
 }
}

MTreeNode.java:

public class MTreeNode<AnyType>{
    //code

    public static MTreeNode<String> createMTree(String filename){
      //my code
  }
}

Upvotes: 0

Views: 1811

Answers (1)

Rehan Javed
Rehan Javed

Reputation: 436

It is working here. Add them in the same package, then it will not give any 'cannot find symbol error'.

I just add the return statement in the method to make it compile fine, because method will return MTreeNode and you don't add any return statement so i just add the "return null" statement.

Working Screenshot

Upvotes: 1

Related Questions