Question 1) Declare and initialize a one dimensional array to hold the numeric index values for each character in your own simulated game theme.
Question 2) Declare and initialize a two dimensional array to hold the textual character attribute data for all characters. Include data for at least two textual attributes per character
public class main {
public static void main(String[] args) {
// Declare 1D array to hold numeric index values
int indices [];
// Initialise array
indices = new int[2];
// Assign values to each item in array
for (int index = 0; index < indices.length; index++) {
indices[index] = index;
}
// Declare 2D array to hold textual character attribute data
String textAttributes [][];
// Initialise array
textAttributes = new String[2][2];
// Assign values to each item in array
textAttributes[0][0] = "Player 1";
textAttributes[0][1] = "Some text attribute";
textAttributes[1][0] = "Player 2";
textAttributes[1][1] = "Some other text attribute";
}
}
Comments
Leave a comment