Using same object in different packages

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

mlecz

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.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Trouble in using different packages in same project in Net Beans IDE

From Dev

Using input types of the same object in different mutations

From Dev

Different Composer packages with same namespace

From Dev

Why are there different packages for the same architecture, but different OSes?

From Dev

Same object in different classes?

From Dev

Different types of the same object

From Dev

Using the same method to instantiate identical object from different namespaces

From Dev

A different object with the same identifier using Spring data jpa with Hibernate

From Dev

Using the same method to instantiate identical object from different namespaces

From Dev

Access different tables using the same type of object (NHibernate, C#)

From Dev

Dynamic HTML using Javascript: Fill same HTML object with different contents

From Dev

Deserialize Xml Using Same Object With Different Element Name

From Dev

combining several iterations of same object in different location using .add() or .merge()

From Dev

Copy data to same classes in different packages

From Dev

Is it possible to create packages with the same name in different organizations?

From Dev

Using different packages for Controllers when using Spring

From Dev

Storing same object in different arrays

From Dev

Reference same object with different tags

From Dev

Same object property with different values

From Dev

how to toggle the same object for different object?

From Dev

Design pattern - different object in, same object returned

From Dev

how to toggle the same object for different object?

From Dev

Same object in one case, different object in another?

From Dev

Two controllers with same name under different packages in Spring

From Dev

Getting help on two functions with the same name in two different packages

From Dev

Java Namespace - Two classes with the same name in different packages

From Dev

Getting help on two functions with the same name in two different packages

From Dev

Sort object array with objects that are not quite the same using two different sort conditions

From Dev

Accessing values from different levels of a nested object within the same append instance using D3.js

Related Related

  1. 1

    Trouble in using different packages in same project in Net Beans IDE

  2. 2

    Using input types of the same object in different mutations

  3. 3

    Different Composer packages with same namespace

  4. 4

    Why are there different packages for the same architecture, but different OSes?

  5. 5

    Same object in different classes?

  6. 6

    Different types of the same object

  7. 7

    Using the same method to instantiate identical object from different namespaces

  8. 8

    A different object with the same identifier using Spring data jpa with Hibernate

  9. 9

    Using the same method to instantiate identical object from different namespaces

  10. 10

    Access different tables using the same type of object (NHibernate, C#)

  11. 11

    Dynamic HTML using Javascript: Fill same HTML object with different contents

  12. 12

    Deserialize Xml Using Same Object With Different Element Name

  13. 13

    combining several iterations of same object in different location using .add() or .merge()

  14. 14

    Copy data to same classes in different packages

  15. 15

    Is it possible to create packages with the same name in different organizations?

  16. 16

    Using different packages for Controllers when using Spring

  17. 17

    Storing same object in different arrays

  18. 18

    Reference same object with different tags

  19. 19

    Same object property with different values

  20. 20

    how to toggle the same object for different object?

  21. 21

    Design pattern - different object in, same object returned

  22. 22

    how to toggle the same object for different object?

  23. 23

    Same object in one case, different object in another?

  24. 24

    Two controllers with same name under different packages in Spring

  25. 25

    Getting help on two functions with the same name in two different packages

  26. 26

    Java Namespace - Two classes with the same name in different packages

  27. 27

    Getting help on two functions with the same name in two different packages

  28. 28

    Sort object array with objects that are not quite the same using two different sort conditions

  29. 29

    Accessing values from different levels of a nested object within the same append instance using D3.js

HotTag

Archive