Ask coding questions

← Back to all posts
Java Calculator
Bunnytoes

I am making a java calculator, but when I type stuff it skips to the end, can someone help

Answered by SixBeeps [earned 5 cycles]
View Answer
Voters
Bunnytoes
Comments
hotnewtop
SixBeeps

In Java, the == operator compares the direct value of both of the values given. Since String variables only store the pointer directing to the value and not the value itself, you cannot compare two strings using ==. When you do that, you're comparing two pointers, which is not what you want.

Use the equals() method on the String object instead.

Bunnytoes

@SixBeeps so

Bunnytoes

@SixBeeps thanks!