How de we pass another class as arguement in main class | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

How de we pass another class as arguement in main class

5th Jun 2017, 1:05 AM
Abhishek Joshi
Abhishek Joshi - avatar
6 Answers
+ 2
what language. what are you trying to do?
5th Jun 2017, 1:25 AM
jay
jay - avatar
+ 2
class mainClass{ public static void main(..){ MyClassName obj = new MyClassName(); function(obj); } void function(ClassName obj){ } }
5th Jun 2017, 1:40 AM
Rrestoring faith
Rrestoring faith - avatar
+ 1
main function signature is fixed by the language.
5th Jun 2017, 2:30 AM
Igor B
Igor B - avatar
+ 1
In any lang main function is the first function that is executed but in java we have static method that can be executed first than main function. u cannot pass another class as argument to the main class. pls share the scenario why u need to pass another class as argument.
5th Jun 2017, 4:58 PM
Nanda Balakrishnan
+ 1
thnks evry1 i got it
6th Jun 2017, 12:48 AM
Abhishek Joshi
Abhishek Joshi - avatar
+ 1
ok
6th Jun 2017, 1:37 AM
Nanda Balakrishnan