Java newbie problem: classes of the same package accessing one another?
- by HH
Test.java and SetWord.java belong to the package tools. Test.java needs to access SetWord but an odd error 'cannot find' SetWord appear. The package limits the visibility, it works without 'package tools;' lines.
How can I acess the SetWords with Test in the same pkg?
In general, how can classes access one another in the same pkg?
Test.java
package tools;
import java.io.*;
import java.util.*;
public class Test{
public static void main(String[] args)
{
//IT CANNOT FIND SetWords despite the same folder, why?
SetWord sw=new SetWord();
System.out.println(st.set("HELLO)");
}
}
SetWord.java
package tools;
import java.io.*;
import java.util.*;
public class SetWord{
public SetWord(){}
public String set(String s)
{
return s.trim().toLowerCase();
}
}