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(); } }
1 Answer
+ 2
In statement, s.summ(a, b) ; a, b are undefined. Use
s.summ(s.a, s.b) ;