Win a copy of Learn Spring Security (video course) this week in the Spring forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

problem with method "validRoomNumber

 
Pepo moussa
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i got a problem with this method which suppose to read a string and check a room number if the 1st letter is upper case or a number and the rest of the room is digits it should return true else false
i do not know what is wrong really but i keep getting error saying else without if so anyone can help
 
Ravikanth kolli
Ranch Hand
Posts: 179
Chrome Eclipse IDE Mac
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi
i think the problem is with the return and not with the if else statements. The final else part returns the value false, but in the if the value is returned if the inner if and the for loop is executed. If they are not executed it is not returning anything. check that out and see if that works..

I could not find any other errors with the paranthesis...
 
Pepo moussa
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
that is my final code nothing with no error but it does not work as i wane it to work ? any idea

 
Pepo moussa
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hello anyone ..i need help :roll:
 
marc weber
Sheriff
Posts: 11343
Java Mac Safari
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How are you testing this?
 
Pepo moussa
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
oh well have example if the string "A123" its true or "123" also true the 1st letter has to be capital or a digit and the rest of the string has to digits so string like that "a123" should not work and return false, or "A123a" also wrong and the method should return false.
 
marc weber
Sheriff
Posts: 11343
Java Mac Safari
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by I moussa:
oh well have example if the string "A123" its true or "123" also true the 1st letter has to be capital or a digit and the rest of the string has to digits so string like that "a123" should not work and return false, or "A123a" also wrong and the method should return false.

Yes, but what happens when you test using these examples?

For example, how would "A123" be split by this tokenizer? And what would happen if there aren't exactly 3 tokens?
[ March 22, 2008: Message edited by: marc weber ]
 
Pepo moussa
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
oh my bad i posted the tokenizer i was not using it anyway, now i finally got my code working
 
Pepo moussa
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
the problem was at my testing i was testing it the wrong way :S
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic