mercredi 7 octobre 2020

How to iterate through a string and print digits only? Java [duplicate]

Can anybody shows me what's wrong with my code?

 String third = ("A1B2C3D4");
    for (int i = 1; i <= third.length(); i++) {
        if (Character.isDigit()) {
            System.out.print(Character);
        } else {
            System.out.print("NOT VALID");
        }

Aucun commentaire:

Enregistrer un commentaire