Problem 1: Array basics

Task 1: Printing

We’ve created an array of existing restaurants in our system! We need your help to print out everything so we do not include the same restaurants.

  1. Use a for Loop to print out the contents of the array.
  2. Use the length() method to find the size of the array.
  3. Look at the example below.

If we are given the array below:

String[] restaurants = { "Burger King", "Chipotle", "Panda Express", "McDonalds" };

the answer should print out:

String answer = "Burger King,Chipotle,Panda Express,McDonalds";

Launch Replit

Task 2: Changing Elements

Oh no! McDonalds is out of food! Change the restaurant list before people start ordering from McDonalds, and be disappointed with no food. Luckily “Pizza Hut” is willing to help out! Replace McDonalds with Pizza Hut in the index.

  1. Launch
  2. Find the index of McDonalds first
  3. Remember quotes around "Pizza Hut"
  4. Look at the example below!

String[] restaurants = {"Burger King", "Chipotle", "Panda Express", "McDonalds"};
//replace "McDonalds" with "Pizza Hut"

Launch Replit