Campbell Ritchie wrote:
Look at their documentation.Varuna Seneviratna wrote:. . . Are they are the same?
That doesn't add to the explanation, I am afraid.. . . What line 29 does is compare the last character in the subStr for alphabetical order with a character in the string that's currently going through the loop.
Campbell Ritchie wrote:Please don't edit old posts; that makes the thread difficult to follow and makes the line numbers appear wrong. I am refusing the first edit.
Please post the cleaned up code as a new post.
Campbell Ritchie wrote:Please explain what you are looking for. I can see, “abcdef,” which I think is an “unbroken alphabetical” substring, and I can also see, “bd'” which I think probably isn't “unbroken alphabetical”.
Please only post the code you are actually running; there is no point in posting commented‑out code. That makes the code very difficult to read.
Please format and indent the code correctly.
After an isBlank() call, there is no need for an isEmpty() call (line 24).
Line 29 is confusing. It looks as though you had stumbled upon a very inefficient way to iterate the String.
Carey Brown wrote:I don't understand why you are going through all those painful steps with sub-strings. You could more easily use two indexes into the input String: begin and end. Increment these as needed and use charAt(idx) to compare the characters. The longest distance between begin and end would be your answer.
You could more easily use two indexes into the input String: begin and end. Increment these as needed and use charAt(idx) to compare the characters.
Huh?
Line 2 is
i = j;
Use the String class's valueOf method on line 42 to convert a char to a String
After an isBlank() call, there is no need for an isEmpty() call (line 24).
Line 29 is confusing.
So it's really a matter of ensuring that your local system preferences are set up compatibly.
Java works with Unicode and only when you set up a print stream with code translation (for example, to ISO-8990-1) will there be a coding issue.
Campbell Ritchie wrote:Try "\\s+" to split on whitespace (any positive number of characters).
The string "boo:and:foo", for example, yields the following results with these parameters:
Regex Limit Result
: 2 { "boo", "and:foo" }
: 5 { "boo", "and", "foo" }
: -2 { "boo", "and", "foo" }
o 5 { "b", "", ":and:f", "", "" }
o -2 { "b", "", ":and:f", "", "" }
o 0 { "b", "", ":and:f" }