File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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;
I agree. Here's the link:
subject: How to access
It's not a secret anymore!