Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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.

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. In the next lesson, well learn how to use nested loops to print out the whole 2D Array. Right now, use the Java Visualizer with the Code Lens button to see what the values are after this code runs. Edit the code to add in an extra row to the seatingChart and add your name and a friends name in the columns of this extra row using assignment statements.

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Introduction to Wireless and Mobile Systems

Authors: Dharma P. Agrawal, Qing An Zeng

4th edition

1305087135, 978-1305087132, 9781305259621, 1305259629, 9781305537910 , 978-130508713

More Books

Students also viewed these Programming questions