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
885
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.
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.
Not a Member yet?
My Account
635
Folks are online
1
members and
634
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?
Boolean Consumer in Java 8.
In JAVA code best way to avoid "if(strResult != null)"
Want to read localized data formats in Java.
How to Change String to Lower Case or Upper case in Java?
How to remove line breaks from a string in java?
How to Get Some Specific Characters From a String In Java?
How to write a multiple line String Array in java?
how to write data in excel from java code?
Interface in java and use of interface
What is super class in java
Categories
All categories
Software Testing
(48)
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
(1)
Puzzles
(4)
Motor Bikes
(11)
Travel
(9)
Electronics
(1)
Entertainment
(2)
OTHER
(18)
Recent
Popular Questions
Registration and login form in PHP?
Tell me best places to visit during holi in india?
What is the best time to visit and the best way to get to the Taj Mahal?
JavaScript- Open a new tab while focusing on an old tab
What should I know before visiting Jim Corbett National Park?
Tell me best places to visit during holi in india?
What is the best time to visit and the best way to get to the Taj Mahal?
What should I know before visiting Jim Corbett National Park?
How to download COVID vaccination certificate and correct personal details?
How to book Vaccine slot quickly ?
All categories
Software Testing
(48)
Programming
(130)
Interview Questions
(28)
My Career
(1)
Puzzles
(4)
Motor Bikes
(11)
Travel
(9)
Electronics
(1)
Entertainment
(2)
OTHER
(18)
Your feedback is highly appreciated