0

Can't find the error in my java

Simple calculator https://code.sololearn.com/cL3efUn15iDR/?ref=app

7th Apr 2022, 9:47 PM
Ahmed Waheed
Ahmed Waheed - avatar
6 Answers
+ 3
Calculator: šŸ‘‰ AS SAID BEFORE: 1. Don't import things you do not use, e.g. your line 3 šŸ‘‰ AS SAID BEFORE: 2. Do not put random blank spaces in methods, e.g. it's System.out.println("something") not System. out.println ("something") 3. Write the method names correctly: It's .nextDouble() and .nextLine()... 4. Do not compare strings with == but with the .equals() method
7th Apr 2022, 10:05 PM
Lisa
Lisa - avatar
0
Can't understand num 4
7th Apr 2022, 10:08 PM
Ahmed Waheed
Ahmed Waheed - avatar
0
Please explain
7th Apr 2022, 10:08 PM
Ahmed Waheed
Ahmed Waheed - avatar
0
Remember that strings are not a primitive type in Java, like integers or characters. String are objects. When you compare two objects with '==', it will compare those objects' memory adresses, not their values.
7th Apr 2022, 10:41 PM
Nick
0
Ok i understand that Now how can i write it
7th Apr 2022, 10:42 PM
Ahmed Waheed
Ahmed Waheed - avatar
0
Choice.equals("+") Alternatively you can use .nextChar() instead of .nextLine() and compare values as you're used to
7th Apr 2022, 10:48 PM
Nick