File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how to declare the length of the word entered?

 
Jack Bolton
Ranch Hand
Posts: 65
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i have now declared an array of String, to capture five words, but i want that every word entered to have a length of 10 letters only.

where do i have to specify that length?


 
marc weber
Sheriff
Posts: 11343
Java Mac Safari
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It sounds like you need to write some validation code around your readLine() method.

while(palab[i].length() != 10) {...
 
Jack Bolton
Ranch Hand
Posts: 65
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you mean like this?
its not working
did i declared it right?

 
marc weber
Sheriff
Posts: 11343
Java Mac Safari
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The validation code would just be used to make sure that the input is a 10-letter word.
 
Jack Bolton
Ranch Hand
Posts: 65
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ok, it's working,
but there is a doubt that i'm having.
I declared a String array to capture five words. String[5]. So everytime i enter a word it takes an element of the array.
But i want that when i enter a word that is longer than 10 letters, it doesn't take an element of the array. So the program will always print the five words encripted.
How do i code this?

here is my code:

[ May 20, 2006: Message edited by: Jack Bolton ]
 
wise owen
Ranch Hand
Posts: 2023
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
 
Jack Bolton
Ranch Hand
Posts: 65
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks wise owen
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic