lundi 10 décembre 2018

Need help for if number casting (Java) [duplicate]

This question already has an answer here:

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