programming-examples/java/Core_Java/Repeat a char for the specified number of times.java

21 lines
432 B
Java
Raw Normal View History

2019-11-15 12:59:38 +01:00
Repeat a char for the specified number of times
public class Test1
{
public static void main(String args[])
{
String ht = repeat('X',7);
System.out.println(ht);
}
public static String repeat(char c,int i)
{
String tst = "";
for(int j = 0; j < i; j++)
{
tst = tst+c;
}
return tst;
}
}