Win a copy of Learn Spring Security (video course) this week in the Spring forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to access

 
Niyas Ahmed Sheikh
Ranch Hand
Posts: 129
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Suppose I want to access the class A's method and variables(ofcourse public) from another class B, in which class B doesn't extend the class A.

Simply I want to access the class A, and to create the instances of class A in the class B, without class B extending class A.

For that what are the criteria or rules for it. I think we can do it in package and if so, some example codings will be very helpful.
 
Mahesh x Bogadi
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
____________________
package a;
public class A
{
public String x;
}
______________________
package b;
import a.A;

public class B
{
private A a;
}
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic