Lo gauy can anyone know about the class and objects in java.this is my class and objects.but it doesn't work | Sololearn: Learn to code for FREE!
Neuer Kurs! Jeder Programmierer sollte generative KI lernen!
Kostenlose Lektion ausprobieren
0

Lo gauy can anyone know about the class and objects in java.this is my class and objects.but it doesn't work

class sum{ int c,a,b; void summ(int a,int b){ c=a+b; } void show(){ System.out.println(c);} } class simple{ public static void main (String a[]){ sum s=new sum(); sum sa=new sum(); s.a=23; s.b=34; s.summ(a,b); s.show(); } }

23rd Aug 2022, 10:36 AM
Mu_G Rahiman
Mu_G Rahiman - avatar
1 Antwort
+ 2
In statement, s.summ(a, b) ; a, b are undefined. Use s.summ(s.a, s.b) ;
23rd Aug 2022, 10:45 AM
Jayakrishna 🇮🇳