cant do addition in java
Go to solution
Solved by Mr_KoKa,
Change
if(input.next() == ("add"))
to
if(input.next().equals("add"))
next() function returns next object and object in java are all pointers, so each object has different pointer address, and comparing object directly will compare their addresses, even if contents are equal addresses are different, to compare string contents you need to use equals member function.
-
Featured Topics
-
Topics
-
joe_ollie909 ·
Posted in CPUs, Motherboards, and Memory4 -
DreamCat04 ·
Posted in PC Gaming0 -
saltycaramel ·
Posted in Tech News1 -
4
-
1
-
1
-
1
-
VinSen ·
Posted in New Builds and Planning4 -
2
-
Fahizzle ·
Posted in CPUs, Motherboards, and Memory0
-
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now