-4
  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.

Iroch
  • 19
  • 6

1 Answers1

1

You use default visibility.

 static connect obj=new connect();   

Acts like a private in other packages. Try

   public static connect obj=new connect();   

Instead.

mlecz
  • 985
  • 11
  • 19