Hello friends
could any one explain why my code is printing true

if(0.0 == -0.0) {
  System.out.println("true");
}
else{
    System.out.println("false");
}

and if if i write this 
if(0.0 == -0.5) {
  System.out.println("true");
}

then it is printing dead code.

please explain

putting a - in front of a 0 is kind of redundant,
in your second test, you have two different values

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.