Chapter 5
Q1) Suppose we wanted to have a quiz where the question could be about naming the president, the capital city, and so on. How would we do this with multidimensional arrays?
A) We would just make the inner array hold three strings, perhaps like this:
String[][] countriesCitiesAndPresidents; //now allocate like this countriesAndCities = new String[5][3]; //and initialize like this countriesCitiesAndPresidents [0][0] = "United Kingdom"; countriesCitiesAndPresidents [0][1] = "London"; countriesCitiesAndPresidents [0][3] = "Cameron";//at time of writing
Q2) In our persistence example, we saved a continually updating string to a file so that it persisted after the app had been shut down and restarted. This is like asking the user to click on a Save button. Summoning all your knowledge of Chapter 2, Getting Started with Android, can you think of a way to save the string without saving it by the button click but just when the user quits the app?
A) Override the...