I'm trying to print out the specific coordinates of a letter in a 2d array. It is a Polybius square in an ADVGVX cipher and I want to just print out one position in the array, for instance "a" i.e. (1,3)
public char[][] cypher = {
{'p', 'h', '0', 'q', 'g', '6'},
{'4', 'm', 'e', 'a', '1', 'y'},
{'l', '2', 'n', 'o', 'f', 'd'},
{'x', 'k', 'r', '3', 'c', 'v'},
{'s', '5', 'c', 'w', '7', 'b'},
{'j', '9', 'u', 't', 'i', '8'},};
I'm trying to do this by using for loops and an if statement.
public void printArrayElement(){
for(int row = 0; row < cypher.length; row++){
for(int column = 0; column < cypher [row].length; column++){
if (cypher[row][column] == cypher [1][3]){
System.out.println(cypher[row][column]);
}
}
}
}
I'm not getting any error messages, nothing is happening.
EDIT:
I'm actually having trouble running this as a main method. With just the above I get the message:
Error: Main method not found in class .PolybiusCypher, please define the main method as: public static void main(String[] args) or a JavaFX application class must extend javafx.application.Application.
When I use public static void main(String[] args)
, I get multiple error messages.