Help in printing the result of the for loop
Dear All,
I am having a problem while writing this java for loop code. I am trying to print "NETProduct" a number of times which is depending on the passed "length" variable and to print after the word "NETProduct" the current value of the length + " ," and when it reached the last "NetProduct", it shoudn't produce "," after the "NETProduct" variable.
As an example:
Code:
String sentence = "";
int length = 4;
for ( i = 1 ; i <= length ; i++)
{
sentence = "NETProduct" + i + ",";
}
So, what I am looking for is for the result:
NETProduct1,NETProduct2,NETProduct3,NETProduct4
and the result is in the same line.
Can you please help