Norm Radder wrote:A comment on the code in the loop
The test: if (i > 0) { on line 6
with } else { on line 18 is slightly confusing.
The else block is for the first time around the loop when i == 0
the if block is for the rest of the iterations.
This would make more sense to me:
Carey Brown wrote:You have several duplicate lines in the two blocks of code that could be moved after the blocks. This follows the "DRY" (Don't Repeat Yourself) principal.
Ron McLeod wrote:Since you don't use the index for anything else, you could simplify the code a bit by using an enhanced for loop:
Ron McLeod wrote:You didn't provide a lot of details, but assuming that TestFileUtils#getTestFileItemsByLaneNumberRange returns a collection of Java objects, I don't understand why you would want to transform them to a JSON representation, and then try to figure out how to reduce it.
If you had a class like this which held the test results:
and TestFileUtils#getTestFileItemsByLaneNumberRange returned a collection of that type, then you could get a list of testcases doing something like this:
Piet Souris wrote:Maybe you can use a Textblock.format? See for instance baeldung textblock. That is a great help when it comes to using Json.
Carey Brown wrote:
result = "<div class=\"parent\"> <div class=\"heading\">"+arr[0]+"</div> <div class=\"heading\">"+arr[1]+"</div></div><div class=\"parent\"> <div class=\"resultname\">"+arr[2]+"</div> <div class=\"resultname\">"+arr[3]+"</div></div>";
Carey Brown wrote:
Jack Tauson wrote:
Carey Brown wrote:Split() is the typical way to do this so if an array is not what you're looking for then what did you have in mind?
If I'm using the split like this:
It's giving me the following output:
I'm mainly looking for values 555,777 ,AB and CD together and not as separate values. Also, I'm not looking for "|" in the output as shown above. Am I doing anything wrong here?
Edit:
Why "|" is showing in the output. Just to clarify more, I'm mainly interested in the values 555, 777, AB and CD only.
Carey Brown wrote:Split() is the typical way to do this so if an array is not what you're looking for then what did you have in mind?
Vasanth Selvamani wrote:Prefix v?