• Post Reply Bookmark Topic Watch Topic
  • New Topic

Validate a Name  RSS feed

 
jhmblvd jm
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am brand new and this is probably a dumb question, how do you determine if there is a space in a name. I tried this
code:
public boolean validateName(String name)
int i = name.indexOf(" ");
if(i > 0);
return true;
else
return false;
 
Jeff Bosch
Ranch Hand
Posts: 805
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And what was your result?

By the way, speaking of name validation, you may want to adjust your display name to meet JR's policy before the sheriff comes around...
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Did that work? Try it with leading and or trailing spaces on a single name and a first and last. Do you know how to get rid of them if they give you trouble?

Here's a neat thing about the language: you can shorten the test and use a single return line:
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!