Meaningless Drivel is fun!
The moose likes Beginning Java and the fly likes How to access Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "How to access" Watch "How to access" New topic

How to access

Niyas Ahmed Sheikh
Ranch Hand

Joined: Jun 15, 2005
Posts: 129

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

Joined: Jul 06, 2004
Posts: 51
package a;
public class A
public String x;
package b;
import a.A;

public class B
private A a;
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
subject: How to access
jQuery in Action, 3rd edition