+ 1
How can I take input string of fixed length in java?
5 Respuestas
+ 2
public class Program
{
public static void main(String[] args) {
String n="atul";
int h=n.length();
if(h<5){
System.out.print ("yes");
}
else{
System.out.print ("error");
}
}
}
+ 2
Vishakha Shrivastav
There is no any other options because String can't be of fixed length. So if you want that user only enter fixed length of string then you have to check its length and throw message if it is greater than fixed length.
See the example of Atul
+ 1
Vishakha Shrivastav Please if you can give one example
0
Like this??