Topics
Mind Fresher Games
Books Deals
Hot Questions
Hot Answers
New Questions
Ask a Question
Explore
Ask a Question
Interview Questions
Java Interview Question
why 130 == 130 returns false in java
why 130 == 130 returns false in java
+2
votes
543
views
asked
in
Java Interview Question
by
anonymous
public class MainClass
{
public static void main(String[] args)
{
Integer i = 130;
Integer j = 130;
System.out.println(i == j);
}
}
Now the output comes as false, can you pls explain why ?
java
java-interview-question
return
Your answer
Thanks for contributing your answer!
Please be sure to answer the question. Provide details with examples and share your research!
Your name to display (optional):
Email me at this address if my answer is selected or commented on:
Email me if my answer is selected or commented on
Privacy: Your email address will only be used for sending these notifications.
Anti-spam verification:
To avoid this verification in future, please
log in
or
register
.
1
Answer
+1
vote
answered
by
anonymous
when you declare using "Integer" class , instead of variable- an object is created an object comparison with == gives false.
Your comment on this answer:
Use comments to reply to other users or notify them of changes. If you are adding new information, edit your post instead of commenting.
Your name to display (optional):
Email me at this address if a comment is added after mine:
Email me if a comment is added after mine
Privacy: Your email address will only be used for sending these notifications.
Anti-spam verification:
To avoid this verification in future, please
log in
or
register
.
Not a Member yet?
My Account
409
Folks are online
2
members and
407
guest online
Related questions
Do you know the suitable option to start a thread in Java ???
Exact use of finally in Java ?
Frequently asked java interview written question
What do you know about Java and what are the supported platforms by Java?
Create an Object instance without using new ?
Difference between a constructor and a method?
Which package is used for pattern matching with regular expressions?
Use of HashMap in multithreaded environment in java.
elaborate thread execution in java?
Reason behind why body returns false?
Categories
All categories
Software Testing
(65)
Programming
(130)
Interview Questions
(28)
HR Interview Question
(2)
Manual Testing Interview Question
(7)
Automation Testing Interview Question
(3)
Java Interview Question
(11)
PHP Interview Question
(4)
My Career
(5)
Puzzles
(4)
Motor Bikes
(11)
Travel
(4)
Electronics
(1)
Entertainment
(2)
OTHER
(17)
Recent
Popular Questions
Registration and login form in PHP?
JavaScript- Open a new tab while focusing on an old tab
MySQL server has gone away error php
get meta tags in PHP
google language translator api php
break looping while loop
PHP installation
Declare PHP Variables
PHP Data Types
MySQL server has gone away error php
All categories
Software Testing
(65)
Programming
(130)
Interview Questions
(28)
My Career
(5)
Puzzles
(4)
Motor Bikes
(11)
Travel
(4)
Electronics
(1)
Entertainment
(2)
OTHER
(17)
Your feedback is highly appreciated