Videos
I am provided a string. This string is a comma separated list of IDs. The list could have one ID, or it could have 1000 IDs (or any number of IDs). I need to determine how many characters the first ID is, whether it's alone or the first of many.
Currently I have a substring that uses indexOf as the end index, and uses the index of a comma. If there is no comma then the damn thing blows up. I have an OR clause that basically says "If this string up to the first comma is 5 digits OR the entire string is 5 digits, then do something".
I thought this would take care of the scenario with no comma. It doesn't. What is the best way to handle this?
EDIT I would share the code, but this is a massive application for work, and I'm guessing I'd get fired for sharing it, and according to the rules of this sub can't share code that isn't runnable. So while I REALLY think the one line I'm having issue with will help illustrate my problem very well, according to the sub rules I can't share it.
Hey guys, I've been working on this Java homework for my class and this whole section about string manipulation is confusing me.
The homework asks to add statements that use the substring method to get the first half and second half of phrase.
I'm assuming that means using the substring method, but I always get errors trying to compile what I put in. So here's the code. I'm not exactly sure how to use the substring method in the way they ask, and my book doesn't really go over it well. Should I be creating another variable or just use what I have?