JAVA Gurus, Check This Little Code!!!! - Programming - Nairaland
Nairaland Forum › Science/Technology › Programming › JAVA Gurus, Check This Little Code!!!! (1499 Views)
| JAVA Gurus, Check This Little Code!!!! by Aphatech(op): 12:43pm On Apr 02, 2016 |
Integer a=100, b=100; System.out.printIn(a == b); Integer c=200, d=200; System.out.printIn(c == d); . . . The use second command print false, why? Let's see how good you are to detect small error!!! |
| Re: JAVA Gurus, Check This Little Code!!!! by APHATHEOLOGY(m): 2:01pm On Apr 02, 2016 |
Where are the JAVA daemons? |
| Re: JAVA Gurus, Check This Little Code!!!! by Nobody: 3:09pm On Apr 02, 2016 |
Integer a=200, b=200;this will give you false as well. int a=200, b=200;this will give you true. Integer a=100, b=100;this will return true in all cases int a=100, b=100;this will return true in all cases Reason: you cannot compare 2 integers the same way you will compare int (they are 2 different things entirely). I ain't got time to teach now o jare. |
| Re: JAVA Gurus, Check This Little Code!!!! by Fulaman198(m): 3:55pm On Apr 02, 2016 |
dhtml18:To expand upon this, when you declare Integer a = 100; you are creating an instance of Object Integer. To check for object content equality, the .equals() method should suffice. The reason why Integer a = 100, b = 100; and (a == b) comes out to false is because they are not pointing or referencing to the same object. |
| Re: JAVA Gurus, Check This Little Code!!!! by Nobody: 5:28pm On Apr 02, 2016 |
Just passing by with my 'java bible' text book firmly held in my armpit. ![]() |
| Re: JAVA Gurus, Check This Little Code!!!! by Fulaman198(m): 7:10pm On Apr 02, 2016 |
crotonite:lol |
Java Gurus Please I Need This Little Assignment Solved ''appreciation Involved" • Java Gurus Help • Excuze Me .... Java Gurus.. Dnt Pass By. • 2 • 3 • 4
Real Time!!! Java And C++ Which Has More Advantage. Drop Reviews Please • People Stealing Programming Jobs on NL • I Need A Web Designer In Portharcourt
