I am working on a simple program that needs to return 3 times a certain substring. For example, a call such as makeThreeSubstr("hello",0,2) should return "hehehe". I have the code ready to return "he", but I don't know an simple way to output the substring three times in a row. Any help is greatly appreciated.
class Main {
public static String makeThreeSubstr (String word, int startIndex, int endIndex)
{
return (word.substring(startIndex, endIndex));
}
public static void main(String[] args){
System.out.println(makeThreeSubstr("hello",0,2)); //should be hehehe
System.out.println(makeThreeSubstr("shenanigans",3,7)); //should be naninaninani
}
}