• Post Reply Bookmark Topic Watch Topic
  • New Topic

The code is giving runtime exception  RSS feed

 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
 
Ranch Hand
Posts: 650
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
First of all, this forum is for Servlets. I think you need to post this in the Beginning Java forum.

Second, pretty good use of the code tags! Most don't get those the first time.

Finally, if you're getting an exception, it would be good to provide that in your question so we can see it. For example, it should include the line number where the exception is occurring, and the actual problem. However, let me ask you one thing: What do you think the code will do if your input value is more than 10 characters in length? Look specifically at line 25: I hope that will give you a hint
 
Author and ninkuma
Marshal
Posts: 66307
152
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moved to Beginner Java.
 
Ranch Hand
Posts: 423
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Change <= operator to: < in line 23

And consider using String.toCharASrray() function instead of copying your strings char by char:
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!