CodeGym
Promotion
CodeGym University
Learning
Course
Tasks
Surveys & Quizzes
Games
Help
Schedule
Community
Users
Forum
Chat
Articles
Success stories
Activity
Reviews
Subscriptions
Light theme
Question
  • Reviews
  • About us
Start
Start learning
Start learning now
  • All questions
Deepak Joshi
Level 17
Nainital
  • 01.05.2019
  • 964views
  • 1comment

What is the reason?

Question about the task Longest sequence
Java Syntax,  Level 8,  Lesson 6
Under discussion
0
Comments (1)
  • Popular
  • New
  • Old
You must be signed in to leave a comment
ThomasLC
Level 16 , Singapore, Singapore
22 May 2019, 17:09
Okay this is way advance, but I'll try to explain. int = primitive data type, stores actual binary value (i.e. "==" compares actual binary value) Integer = it's a class and keeps a cache of Integer instances in the range of -128 to 127 (meaning between these numbers it compares the actual value and its true, outside these values it's comparing references which "==" will not be sufficient) in the first example, if you changed "==" to ".equals()" it will work as well.
+1
Learn
  • Registration
  • Java Course
  • Help with Tasks
  • Pricing
  • Game Projects
  • Java Syntax
Community
  • Users
  • Articles
  • Forum
  • Chat
  • Success Stories
  • Activity
  • Affiliate Program
Company
  • About us
  • Contacts
  • Reviews
  • Press Room
  • CodeGym for EDU
  • FAQ
  • Support
CodeGym CodeGym is an online course for learning Java programming from scratch. This course is a perfect way to master Java for beginners. It contains 1200+ tasks with instant verification and an essential scope of Java fundamentals theory. To help you succeed in education, we’ve implemented a set of motivational features: quizzes, coding projects, content about efficient learning and Java developer’s career.
Follow us
Interface language
Programmers Are Made, Not Born © 2023 CodeGym
MastercardVisa
Programmers Are Made, Not Born © 2023 CodeGym
This website uses cookies to provide you with personalized service. By using this website, you agree to our use of cookies. If you require more details, please read our Terms and Policy.