user2825312
user2825312

Reputation: 11

Why is this a "cannot find symbol" error?

I'm finishing up my project but keep running into this error. I don't get it because PermutationData is another class with static String[][] ROTOR_SPECS (an array) and i'm checking to see if the element x[0] is inside PermutationData but my compiler keeps recognizing PermutationData as a a variable not a class.... I'm inside my Rotor class right now.

Rotor.java:90: error: cannot find symbol

for (String[] x : PermutationData.ROTOR_SPECS) {
                  ^
symbol: variable PermutationData
location: class Rotor
        if (type() == x[0]) {
            Index1 = toIndex(x[1].charAt(p));

This is my PermutationData.java class.

class PermutationData {

/** The names and definitions of the rotors and reflectors in M4.  The
 *  first string in each entry is the name of a rotor or reflector.  The
 *  second is a 26-character string whose first character is the mapping
 *  (when the rotor is at the 'A' setting), of 'A' in the right-to-left
 *  direction, whose second is that of 'B', etc.
 *
 *  The third entry, if present, is the inverse of the
 *  second---the left-to-right permutation of the rotor.  It is
 *  not present for reflectors.
 *
 *  The fourth entry, if present, gives the positions of the
 *  notches. These are the settings of the rotors just before the
 *  wheels advanced (wheels advance before a character is
 *  translated).  Other written accounts of the Enigma generally
 *  show instead the character settings just after a character is
 *  coded (e.g., 'R', rather than 'Q', or 'A' rather than 'Z').
 *  The entry is absent in rotors that do not advance. */

static final String[][] ROTOR_SPECS = {
    { "I", "EKMFLGDQVZNTOWYHXUSPAIBRCJ", "UWYGADFPVZBECKMTHXSLRINQOJ",
      "Q" },
    { "II", "AJDKSIRUXBLHWTMCQGZNPYFVOE", "AJPCZWRLFBDKOTYUQGENHXMIVS",
      "E" },
    { "III", "BDFHJLCPRTXVZNYEIWGAKMUSQO", "TAGBPCSDQEUFVNZHYIXJWLRKOM",
      "V" },
    { "IV", "ESOVPZJAYQUIRHXLNFTGKDCMWB", "HZWVARTNLGUPXQCEJMBSKDYOIF",
      "J" },
    { "V", "VZBRGITYUPSDNHLXAWMJQOFECK", "QCYLXWENFTZOSMVJUDKGIARPHB",
      "Z" },
    { "VI", "JPGVOUMFYQBENHZRDKASXLICTW", "SKXQLHCNWARVGMEBJPTYFDZUIO",
      "ZM" },
    { "VII", "NZJHGRCXMYSWBOUFAIVLPEKQDT", "QMGYVPEDRCWTIANUXFKZOSLHJB",
      "ZM" },
    { "VIII", "FKQHTLXOCBJSPDZRAMEWNIUYGV", "QJINSAYDVKBFRUHMCPLEWZTGXO",
      "ZM" },
    { "BETA", "LEYJVCNIXWPBQMDRTAKZGFUHOS", "RLFOBVUXHDSANGYKMPZQWEJICT" },
    { "GAMMA", "FSOKANUERHMBTIYCWLQPZXVGJD", "ELPZHAXJNYDRKFCTSIBMGWQVOU" },
    { "B", "ENKQAUYWJICOPBLMDXZVFTHRGS" },
    { "C", "RDOBJNTKVEHMLFCWZAXGYIPSUQ" }
};

}

Upvotes: 1

Views: 291

Answers (3)

Innovation
Innovation

Reputation: 1534

I think that your PermutationData.java class has default level package access and you are calling it from some other package.Because of this PermutationData.java class can't be accessed.

Please make PermutationData.java public that can solve your problem.

Another thing is yes ROTOR_SPECS is a variable of type String[][].So you can first store it somewhere in your program and assign it to some other variable and then check for its existence.

Try and run this.It is working.

for (String[] x : PermutationData.ROTOR_SPECS) {  
             System.out.println(x[0]);
}

Upvotes: 0

iamgarun
iamgarun

Reputation: 1

Along with the answer by @alfasin, make sure that you have imported PermutationData

Upvotes: 0

Nir Alfasi
Nir Alfasi

Reputation: 53545

If ROTOR_SPECS is indeed a method, you should call it using brackets: PermutationData.ROTOR_SPECS()

otherwise the compiler thinks it's a variable!

Upvotes: 3

Related Questions