September 2016
Beginner to intermediate
1089 pages
23h 8m
English
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 ...
Read now
Unlock full access