How to call a class from another class in java? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 6

How to call a class from another class in java?

If i have 2 different classes, how can i make a third class to call the other two?

28th Jul 2017, 11:46 PM
Saori 劉
Saori 劉 - avatar
4 Answers
+ 8
thank you!!
10th Aug 2017, 8:19 PM
Saori 劉
Saori 劉 - avatar
+ 6
thank you!
29th Jul 2017, 12:31 AM
Saori 劉
Saori 劉 - avatar
+ 4
By 'calling a class' do you mean, 'call a method in another class'?. If it is static: myClassName.method(); if it is not static: myObjectName.method(); The method cannot be private, or protected (assuming this isn't Inheritiance).
29th Jul 2017, 12:12 AM
Rrestoring faith
Rrestoring faith - avatar
0
extends for class implements for interface
10th Aug 2017, 5:22 AM
Anıl Öztürk
Anıl Öztürk - avatar