package A;
//it has a class to connect to a database
public class refer {
static connect obj = new connect();
}
I want to use the above object in another package
import A.refer;
class X {
public int calculate() {
int result = refer.obj.methodname();
return result;
}
}
Error i am getting- The field refer.obj is not visible.
You use default visibility.
static connect obj=new connect();
Acts like a private in other packages. Try
public static connect obj=new connect();
Instead.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments