Sign Up

Have an account? Sign In Now

Sign In

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask question.

Forgot Password?

Need An Account, Sign Up Here
Tech Answered Logo Tech Answered Logo
Sign InSign Up

Tech Answered

Tech Answered Navigation

  • Home
  • Tutorials
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • About Us
  • Blog
  • Contact Us
Home / Questions /Q 765
Next
In Process
Aniya
Aniya

Aniya

  • India
  • 67 Questions
  • 38 Answers
  • 2 Best Answers
  • 111 Points
View Profile
  • 1
Aniya
Asked: September 12, 20202020-09-12T19:56:26+05:30 2020-09-12T19:56:26+05:30In: Java

java equals int cannot be dereferenced how to fix

  • 1

I wrote a java class which has equals method in it,and in the return type i used two int values (obj1 and obj2 ) these two instances are of int,and when i try to execute this java code i faced the following issue “java equals int cannot be dereferenced” why this int cannot be deferenced error and how can i fix this….

@Override
public boolean equals(Object myobj){
if (null == myobj)return false;
if (this == myobj)return true;

return obj1.equals(that.getAddition()) && obj2.equals(getDiv());
}

how to fix java equals int cannot be dereferencedint cannot be dereferenced javajava equals int cannot be dereferencedjava errors
  • 2
  • 267
  • 0
  • 0
Answer
Share
  • Facebook

    Related Questions

    • e java.lang.noclassdeffounderror javax/xml/bind/jaxbexception
    • java error code 1603 how to fix
    • exception in thread awt-eventqueue-0'' java awt awterror boxlayout can t be shared
    • java error: could not find or load main class how to fix
    • java error boolean cannot be dereferenced
    • How to solve null pointers should not be dereferenced sonar fix
    • Exception get java.lang.NullPointerException when setting up c/c++ build 2020

    2 Answers

    • Voted
    • Oldest
    • Recent
    1. Namrata Podder
      2020-10-12T12:16:38+05:30Added an answer on October 12, 2020 at 12:16 pm

      I think you’re having a problem because int is a primitive type. And only object are reference types
      Either you should use Integer , as in the wrapper class or use == instead of equals. I guess this solves java equals int cannot be dereferenced error.

      • 1
      • Reply
      • Share
        Share
        • Share on WhatsApp
        • Share on Facebook
        • Share on Twitter
        • Share on LinkedIn
    2. neha

      neha

      • India
      • 1 Question
      • 2 Answers
      • 0 Best Answers
      • 24 Points
      View Profile
      neha
      2021-01-12T22:12:42+05:30Added an answer on January 12, 2021 at 10:12 pm

      int is not an object it is a primitive data type and objects are reference type. So instead of equals use == and return obj1 and obj2 separately. hope it solves your problem

      • 0
      • Reply
      • Share
        Share
        • Share on WhatsApp
        • Share on Facebook
        • Share on Twitter
        • Share on LinkedIn
    Leave an answer

    Leave an answer
    Cancel reply

    Browse

    Choose from here the video type.

    Put here the video id : https://www.youtube.com/watch?v=sdUUx5FdySs Ex: 'sdUUx5FdySs'.

    Sidebar

    Ask A Question

    Stats

    • Questions 661
    • Answers 784
    • Posts 7
    • Best Answers 29

    Related Questions

    • java error a jni error has occurred please check your

      • 1 Answer
    • how to set java path and classpath in windows 10

      • 0 Answers
    • java error application blocked by security settings

      • 1 Answer
    • java. lang. NullPointerException

      • 0 Answers
    • what java is used for ?

      • 1 Answer
    • Recent
    • Comments
    • Tags
    • Android 11 OS Features List | All You need to know about ANDROID 11

      Android 11 OS Features List | All You need to

    • Things to consider when buying a AC

      Things to consider when buying a AC

    • Things to consider when buying a printer

      Things to consider when buying a printer

    ac buying guide android 11 android 11 os features android 11 release date best specs for new smartphone to buy buy best smartphone android features list of android 11 google news Google News App google search app how to find best smart phone key configuration for best laptop key points before buying ac laptop buying guide laptop buying key points laptop choosing points limit google news notifications new smartphone choosing guide new things on android 11 points to remember for buying laptop printer buying guide remove google news smart phone buying guide stop google news notifications things to consider before buying laptop turn off google news turn off google news notifications

    Recent Questions

    • Which is better, XAMPP or WAMP ?

      • 0 Answers
    • how to fix lag in pubg mobile really slow

      • 1 Answer
    • whatsapp or signal app which one is better

      • 0 Answers
    • how to show battery percentage on android with Number

      • 0 Answers
    • how to set background image in html example program

      • 0 Answers

    Explore

    • Home
    • Communities
    • Questions
      • New Questions
      • Trending Questions
      • Must read Questions
      • Hot Questions
    • Polls
    • Tags
    • Badges
    • Users
    • Help

    Footer

    Recent Comments

    • sita on how to fix lag in pubg mobile really slow
    • jahnavi on java error a jni error has occurred please check your installation and try again
    • nora khan on how to contact youtubers to review your product
    • dynamicapps5 on How does signal app earns money
    • neha on How to solve null pointers should not be dereferenced sonar fix
    Ask A Question

    Questions Categories

    • Android
    • Animation
    • Artificial Intelligence and Machine Learning
    • AWS
    • C Language

    Archives

    • September 2020
    • August 2020
    • July 2020

    Social media

    Terms & Privacy policy
    © 2020 All Rights Reserved @
    Techanswered.

    Insert/edit link

    Enter the destination URL

    Or link to existing content

      No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.