Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

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 a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

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

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6031021
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T05:07:22+00:00 2026-05-23T05:07:22+00:00

I work with a Java project and Eclipse(Version 3.6.2) as IDE, in a enum

  • 0

I work with a Java project and Eclipse(Version 3.6.2) as IDE, in a enum comparison i get a strange behaviour, following an example of the weirdness :

Global Variable :

StatusType status = StatusType.SIGNATURE;

                     

Code :

                String trsStatus = "END";
            if(trsStatus.equals("END") && (this.status.compareTo(StatusType.SIGNATURE) != 0)){
                //Do something
                }

This comparison succeeds and enter in the if block, Why ? In this case the second evaluation(this.status.compareTo(StatusType.SIGNATURE) != 0) of the if statements fail because the result is false ! Why java however enter in the block ???

If i evaluate the expression on the expression watcher of eclipse debugger the value of the statements are :

trsStatus.equals("END") —> true

(this.status.compareTo(StatusType.SIGNATURE) != 0) —> false

I’ve done another test, if i assign the result of the second expression in the if statements to a boolean variable :

boolean sign = (this.status.compareTo(StatusType.SIGNATURE) != 0);

i get this result :

(this.status.compareTo(StatusType.SIGNATURE) != 0) —> false

sign —> true

Why ?!?

How this can be possible ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T05:07:23+00:00Added an answer on May 23, 2026 at 5:07 am

    Could it be that StatusType overrides compareTo() in some weird way?

    Are there any other threads that could be changing the value of the status field?

    In any case, you should use equals() or even == rather than compareTo() here.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

For a new Java web project I thought about using: Eclipse as IDE Mercurial
I'm trying to get eclipse to work with MinGW. I've done the following: Downloaded
I recently started using Eclipse at work for my Java servlet projects. I've been
I recently got involved in a Java project at work: we're using MyEclipse for
I work on a project that uses multiple open source Java libraries. When upgrades
I am a Java programmer and need to work on a Flex/ActionScript project right
Many parts of the Java API work differently depending on platform defaults, for example,
In my Android application in Eclipse, I get the following error. UNEXPECTED TOP-LEVEL EXCEPTION:
Today I see a strange behaviour of Eclipse 3.5.2 for the first time in
In my Android appliction in eclipse I get the following error: [2011-11-03 19:39:12 -

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

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.