Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

How to call a Java class from another java class ??

Hi ..... can somebody plz tell me

How to call a Java Class from another Java Class assuming both in the same Package??

I want to call the entire Java Class (not any specific method only........I want all the functionalities of that class)

Please provide me some slotuions!!

Waiting for some fast replies!!

Regards

Smita Mohanty

Former Member
Former Member replied

Hi Smita,

you just need to create an object of that class,thats it. Then you will be able to execute each and every method.

e.g.

you have developed A.java and B.java, both are in same package.

in implementaion of B.java

class B

{

A obj = new A();

//to access A's methods

A.method();

// to access A's variable

//either

A.variable= value.

//or

A.setvariable() or A.getvariable()

}

0 View this answer in context
Not what you were looking for? View more on this topic or Ask a question