0
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?

John Kugelman
  • 349,597
  • 67
  • 533
  • 578
Golden
  • 11
  • There is no line `studentPhotos.printAllPermutations(permList, nameList);` in the code you posted. – John Kugelman Jul 17 '22 at 01:16
  • I know, I'm not sure why its saying that when its giving me the error. – Golden Jul 17 '22 at 01:20
  • The posted code is running fine. While the posted error is not look like the error for the same code. I think you are **not using any IDE** and you are calling the method ***printAllPermutations()*** instead of ***allPermutations()*** using the object **studentPhotos** of ***PhotoLineups*** class like studentPhotos.printAllPermutations(permList, nameList); **Note**: you can call static method directly inside main method without object reference. – Jimmy Jul 17 '22 at 02:06

1 Answers1

0

Okay, I am editing this now that you added that comment.

From what I see in your error you are trying to call the method printAllPermutations(ArrayList<String>, ArrayList<String>) when that method does not exist. If I had to guess I would guess that wherever you calling the method you accidently typed printAllPermutations instead of allPermutations

Moraban
  • 69
  • 7