0

Why am i getting an error method repeat(int) is undefined for the type string

public class Main { public static void main(String[] args) { for (int i=1;i<=5;i++) { System.out.println((Integer.toString((i*2)-1)).repeat(i)); } } }

12th Aug 2020, 11:52 AM
John
John - avatar
2 Respuestas
+ 2
String.repeat() method available since Java 11, you might wanna check your Java installation version. P.S. Code runs fine in Code Playground.
12th Aug 2020, 12:05 PM
Ipang
+ 1
Thanks
12th Aug 2020, 10:50 PM
John
John - avatar