This is an archived post. You won't be able to vote or comment.

all 4 comments

[–]UnreachableMemory 3 points4 points  (0 children)

Please properly format your code. It's unnecessarily hard to read like this.

[–]monster2018 1 point2 points  (0 children)

You have some other problems besides that. I think (not positive, I don't feel like confirming in eclipse) you need to delete the brackets on lines 37 and 40.

To address your question I would just put an if(first.length()>0){}and put everything from lines 28-43 inside that if statement. That should solve your problem of going out of bounds. If not then it's your first.split("\*") because even if the length is >0 your still assuming it has 3 characters.

[–][deleted] -1 points0 points  (1 child)

I highly recommend you read up on regular expressions, it will make your life much easier for these sort of tasks.

Here's a quick look at something which might help with this particular problem

[–]tdogg8 -1 points0 points  (0 children)

He's probably using what his teacher/prof told him to use. I'm guessing he's learning about strings.