Learn

When we were using arrays, we could rewrite entries by using bracket notation to reassign values:

String[] shoppingCart = {"Trench Coat", "Tweed Houndstooth Hat", "Magnifying Glass"}; shoppingCart[0] = "Tweed Cape"; // shoppingCart now holds ["Tweed Cape", "Tweed Houndstooth Hat", "Magnifying Glass"]

ArrayList has a slightly different way of doing this, using the set() method:

ArrayList<String> shoppingCart = new ArrayList<shoppingCart>(); shoppingCart.add("Trench Coat"); shoppingCart.add("Tweed Houndstooth Hat"); shoppingCart.add("Magnifying Glass"); shoppingCart.set(0, "Tweed Cape"); // shoppingCart now holds ["Tweed Cape", "Tweed Houndstooth Hat", "Magnifying Glass"]

Instructions

1.

Modify sherlocksToDos so that the value at "play violin" becomes "listen to Dr. Watson for amusement".

2.

Modify poirotsToDos so that the value at "trim mustache" becomes "listen to Captain Hastings for amusement".

Take this course for free

By signing up for Codecademy, you agree to Codecademy's Terms of Service & Privacy Policy.
Already have an account?