Please use basic Java program and comment so that I understand what is going on.
public class lab1 { public static String multiConcat(String s, int n) { String result = ""; // set result to empty string for (int i = 0; i < n; i++) { // loop n times result += s; // every time through the loop. add s to result } return result; // return final result } public static void main(String[] args) { System.out.println(multiConcat("hi", 4)); } }
Get Answers For Free
Most questions answered within 1 hours.