import java.util.Scanner;
import java.util.ArrayList;
public class PhotoLineups {
public static void allPermutations(ArrayList<String> permList, ArrayList<String> nameList) {
if (nameList.isEmpty()) {
for (int i = 0; i < permList.size(); i++) {
if(i == permList.size()-1) {
System.out.print(permList.get(i));
}
else {
System.out.print(permList.get(i)+", ");
}
}
System.out.println();
} else {
for (int i = 0; i < nameList.size(); ++i) {
ArrayList<String> newPerm = new ArrayList<String>(permList);
newPerm.add(nameList.get(i));
ArrayList<String> newNameList = new ArrayList<String>(nameList);
newNameList.remove(i);
allPermutations(newPerm, newNameList);
}
}
}
public static void main(String[] args) {
Scanner scnr = new Scanner(System.in);
ArrayList<String> nameList = new ArrayList<String>();
ArrayList<String> permList = new ArrayList<String>();
String name;
while (true) {
name = scnr.next();
if (name.equals("-1")) break;
nameList.add(name);
}
allPermutations(permList, nameList);
}
}
I get this 1 and only error when I run it on zyBooks:
Tests studentPhotos.printAllPermutations() correctly creates and outputs permutations
Compilation failed:
zyLabsUnitTest.java:27: error: cannot find symbol
studentPhotos.printAllPermutations(permList, nameList);
^
symbol: method printAllPermutations(ArrayList<String>,ArrayList<String>)
location: variable studentPhotos of type PhotoLineups
1 error
Can anyone help me fix this please?