+ 1

java question

can I assign variable in main method to equal specific instances Ex Spc m = new m (2,3); int a = f.m , r.m; where 2 = f.m and 3 = r.m

2nd Jul 2020, 4:43 PM
Khaled Almutairi
4 Answers
+ 4
You can but you have all wrong syntaxes.. If there is a proper class for Spc with 2 default arguments f,m, then Spc m = new Spc(2,3); int a = m.f; int b = m.r;
2nd Jul 2020, 5:58 PM
Jayakrishna 🇼🇳
+ 1
(About your DM question:) DM is not working now for me, I see other complaints or may be for me only in my mobile..(am not activated my id)... Combine means how? If you mean int a = m.f + m.r; // this is valid syntax..
2nd Jul 2020, 8:02 PM
Jayakrishna 🇼🇳
+ 1
Khaled Almutairi print 'a' will print only a's value, it may be anything but what is 3 there additionally? Can you show your print statements to understand it clearly and how you want output? In java System.out.print(a) ; prints only a value, if it 2 then 2. If it is 3 then 3.. If it not enough, then post your code and mention what is your expected output..
2nd Jul 2020, 9:01 PM
Jayakrishna 🇼🇳
0
Jayakrishna🇼🇳 i mean to have them show up next to each other , no math included so when ever i print (a )it will show both numbers side by side 2 3
2nd Jul 2020, 8:48 PM
Khaled Almutairi