I recently posted about a school project im working on and received a lot of help. Im still working on this and I've encountered a new issue: I ask the user to input the name of a school subject, but I need it to be from 1 to 15 characters max, if he were to input more than 15 characters, the result I want to print would not be what I expect as I already have thought of the design. Tried using if(mystringarray[arrayname]>15) but I know this is meant for Integers. Any help would be appreciated, im willing to learn.
//---------------------------------------------------------------------------
String arrayer[] = new String[z];
for(multi=0; multi<arrayer.length; multi++){
do{
out.print("\n");
out.print("Introduzca el nombre de la materia "+(multi+1)+" : ");
try{
arrayer[multi]=LeerTeclado.nextLine();
if(arrayer[multi]>15){
out.println ("\nSubject name should be shorter than 15 characters\n");
continue;
}
break;
}catch (InputMismatchException ex) {
out.println("Subject name should be shorter than 15 characters\n");
LeerTeclado.next();
}
}while(true);
}
//---------------------------------------------------------------------------