我正在完成我的项目,但一直遇到这个错误。我不明白,因为 PermutationData 是另一个具有静态 String[][] ROTOR_SPECS (一个数组)的类,我正在检查元素 x[0] 是否在 PermutationData 内部,但我的编译器一直将 PermutationData 识别为一个变量,而不是一堂课....我现在在我的转子班里。
Rotor.java:90:错误:找不到符号
for (String[] x : PermutationData.ROTOR_SPECS) {
^
symbol: variable PermutationData
location: class Rotor
if (type() == x[0]) {
Index1 = toIndex(x[1].charAt(p));
这是我的 PermutationData.java 类。
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" }
};
}