I have made a program for understanding this operator bt can anyone explain why in 2nd case it is giving answer 0?? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

I have made a program for understanding this operator bt can anyone explain why in 2nd case it is giving answer 0??

https://code.sololearn.com/c4Rki38Xrkqe/?ref=app

31st Jul 2017, 10:10 AM
Aman Kumar
5 Answers
+ 6
oops sorry int x; //x is null and null is equivalent to 0 //in the obj1 you set argument x to this.x while this.x is null(or 0) but System.out.print(x) just take this.x so this is why it print 0 out //Da heck my grammar a lot (I spoke in the word of another programming language)
31st Jul 2017, 10:24 AM
Yanothai Chaitawat
Yanothai Chaitawat - avatar
+ 5
I'm not sure with java bc I don't like it You assign x into int but no value given yet so it is undefined and undefined kinda like 0 in computer
31st Jul 2017, 10:14 AM
Yanothai Chaitawat
Yanothai Chaitawat - avatar
0
can uh plz elobarate it??
31st Jul 2017, 10:16 AM
Aman Kumar
0
but i am giving it value 10 like ob.s (10);
31st Jul 2017, 10:22 AM
Aman Kumar
0
then why it is giving 10 in ist case @Very_Hard
31st Jul 2017, 10:28 AM
Aman Kumar