Answer:
see explaination for program code
Explanation:
program code below:
class Names{
public static String[] makeNames(String[] array1, String[] array2){
if(array1.length == 0) return array2;
if(array2.length == 0) return array1;
String[] res = new String[array1.length*array2.length];
int k = 0;
for(int i=0;i<array1.length;i++){
for(int j=0;j<array2.length;j++){
res[k++] = array1[i] + " " + array2[j];
}
}
return res;
}
public static String[] makeNames(String[] array1, String[] array2, String[] array3){
return makeNames(makeNames(array1, array2), array3);
}
public static void print(String[] array){
for(String name : array){
System.out.println(name);
}
}
public static void main(String[] args) {
String[] first = {"David", "Mike", "Katie", "Lucy"};
String[] middle = {"A","B", "C", "D", "E"};
String[] last = {};
String[] names = makeNames(first, middle, last);
print(names);
print(names);
}
}