I have string
String str="<td>"
And my input count=5
Is their any way in which I can get string equal to the counter
output string would be str="<td><td><td><td><td>"
I have string
String str="<td>"
And my input count=5
Is their any way in which I can get string equal to the counter
output string would be str="<td><td><td><td><td>"
String str = "";
for (int i = 0; i < count; i++) {
str = str + "<td>";
}
System.out.println(str);
Create a string as a new character array contraining count
number of characters. The default character is the null character \0
. Simply replace all null characters with your required String
.
String str = new String(new char[count]).replace("\0", "<td>");
You can manually create it using StringBuilder
String str="<td>"
StringBuilder builder = new StringBuilder();
for(int i=0; i<count; i++){
builder.append(str);
}
System.out.println(builder.toString());