This question already has an answer here:
- How do I compare strings in Java? 23 answers
I was wondering how to make string work so if it's a number, it'll do this, and if it's not a number do this. I know about switch statements, so I was just wondering if there is any way to make it shorter. Thanks!
String s = 20
if(s = 20) {
System.out.println(s + " equals " + " 20");
}else if(s != 20) {
System.out.println("s is " + s));
}
I'm new to Java and stackoverflow, so if I need to be more specific just let me know!
Aucun commentaire:
Enregistrer un commentaire