import java.util.Scanner;
public class userInputTest {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
for(int i = 0; i>-1; i=i+1){
String[] giveMeAString = new String[i+1];
String x = sc.next();
giveMeAString[i]=x;
if(i>=0){
if (giveMeAString[i].length() < giveMeAString[i-1].length()){
System.out.println("The string is shorter than previous string!");
break;}
}
}
}
}
i want to loop until present user inputs length is less than previous user input length.
i haven't solved it for a while after many tries and wonderings.
what am i doing wrong? i want to use Array, because i also want to print the user inputs out later on.
the only problem i have now is to make the written code work.
Aucun commentaire:
Enregistrer un commentaire