Question
Try the code below. Did it print what you expected? When you print a two dimensional array you just get the reference to the object.
Add another row of data to the arrays by changing the size of the arrays and adding in the assignment statements for the cells in those rows. Use the CodeLens button to see the contents of the array.
public class TwoDArraySet { public static void main(String[] args) { // declare arrays int[][] ticketInfo; String[][] seatingChart;
// create arrays ticketInfo = new int [2][3]; seatingChart = new String [3][2];
// initialize the array elements ticketInfo[0][0] = 15; ticketInfo[0][1] = 10; ticketInfo[0][2] = 15; ticketInfo[1][0] = 25; ticketInfo[1][1] = 20; ticketInfo[1][2] = 25; seatingChart[0][0] = \"Jamal\"; seatingChart[0][1] = \"Maria\"; seatingChart[1][0] = \"Jacob\"; seatingChart[1][1] = \"Suzy\"; seatingChart[2][0] = \"Emma\"; seatingChart[2][1] = \"Luke\";
// print the contents System.out.println(ticketInfo); System.out.println(seatingChart); } }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started