₦airaland Forum

Welcome, Guest: RegisterLoginWith GoogleTrendingRecentNew

Stats: 3,331,153 members, 8,448,889 topics. Date: Tuesday, 21 July 2026 at 02:37 AM

Toggle theme

JAVA Gurus, Check This Little Code!!!! - Programming - Nairaland

Nairaland ForumScience/TechnologyProgrammingJAVA Gurus, Check This Little Code!!!! (1517 Views)

1 Reply (Go Down)

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;
System.out.println(a == b);
this will give you false as well.

int a=200, b=200;
System.out.println(a == b);
this will give you true.



Integer a=100, b=100;
System.out.println(a.equals(b));

Integer c=200, d=200;
System.out.println(c.equals(d));
this will return true in all cases


int a=100, b=100;
System.out.println(a==b);

int c=200, d=200;
System.out.println(c==d);
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:
this will give you false as well.


this will give you true.




this will return true in all cases



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.
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. grin
Re: JAVA Gurus, Check This Little Code!!!! by Fulaman198(m): 7:10pm On Apr 02, 2016
crotonite:
Just passing by with my 'java bible' text book firmly held in my armpit. grin
lol
1 Reply

Java Gurus Please I Need This Little Assignment Solved ''appreciation Involved"Java Gurus HelpExcuze Me .... Java Gurus.. Dnt Pass By.234

What Freelancers Should Make Their Clients UnderstandWatsap Group For Agricultural Machinery FabricatorsI Need Help On Laravel With Voyager