Hello first post here hopefully I'm doing it right. I am currently stuck in a problem figuring out if everything in the string are integers or not. I managed to get the yes for each character of the string checked but each time it loops through each character in string i get a new "yes" and need just a yes if EVERY character in string is an integer.
import java.util.Scanner;
public class LabProgram {
public static void main(String[] args) {
Scanner scnr = new Scanner(System.in);
String userString;
int i;
userString = scnr.next();
for (i = 0; i < userString.length(); ++i) {
if (Character.isDigit(i) == true) {
}
System.out.print("yes");
}
}
}
If I input "1995" my output is "yesyesyesyes", while I need an output of just "yes".