Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

length  RSS feed

 
Bob Holland
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi again, what is the syntax to chech that a string variable has the right ammount of charcters, i think its something like


if (variable lenght < 0)

thanks in advance Bob
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes its something like that. The JavaDocs for the String class will tell you for certain.
 
Bob Holland
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,, i cant find the syntax there anywhere

what i want it to do is

if the variable is less than 13 charachters long then print an error,
 
Nigel Browne
Ranch Hand
Posts: 703
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Bob Holland:
hi,, i cant find the syntax there anywhere


Did you look at the method length ?
length() Returns the length of this string.
 
Layne Lund
Ranch Hand
Posts: 3061
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Remember that String is a class, so when you find a method name to use with it, the syntax is exactly the same as calling a method on any other class.

Keep Coding!

Layne
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!