0

Java Scanner

import java.util.Scanner; public class Program { public static void main(String[] args) { String a = "a"; Scanner b = new Scanner(System.in); String c = b.next(); System.out.println("Odessa its:"); System.out.println("a - City"); System.out.println("b - Country"); if(a == c){ System.out.println("You win"); } else { System.out.println("You lose"); } What you lose if you enter the value of a

15th Dec 2017, 12:24 PM
MARKO
MARKO - avatar
5 Respuestas
+ 14
// That's why we use the equals() method instead ;) import java.util.Scanner; public class Program { public static void main(String[] args) { String a = "a"; Scanner b = new Scanner(System.in); String c = b.next(); System.out.println("Odessa its:"); System.out.println("a - City"); System.out.println("b - Country"); if(a.equals(c)){ System.out.println("You win"); } else { System.out.println("You lose"); } } }
15th Dec 2017, 12:36 PM
Dev
Dev - avatar
+ 12
It's okay @Marko, you can still have a quick look at it in the Java course. https://www.sololearn.com/Course/Java/?ref=app
15th Dec 2017, 12:43 PM
Dev
Dev - avatar
+ 4
https://www.sololearn.com/Discuss/321242/?ref=app
15th Dec 2017, 12:35 PM
Vukan
Vukan - avatar
+ 4
dev thx oh I have not yet learned this method, or rather I did not know about it at all 1 day I learn the language of java
15th Dec 2017, 12:39 PM
MARKO
MARKO - avatar
0
I have learned the equals() thanks to this but can you tell me the greater than or less than equivilent.
24th May 2020, 2:49 AM
Code214
Code214 - avatar