Extremely basic array question as I've seen it done both ways and I want to know the general consensus on what is the proper way as I have a project I've had to complete and realized I've seen a few snippets of code perform the loading of array data in a weird way and I'm just wondering if it is my lack of knowledge that thinks it is weird.
An array can be loaded either vertically or horizontally depending on how the objects are entered. With the two types of string arrays creating two different types of structures.
With capitals below creating a more vertical structure that would create essentially 2 columns with 50 rows and capitalCities creating 50 columns with 2 rows.
The novice in me believes that the 1st version of this with the city pairs in the vertical version of this is the accurate way to do this, but I'm honestly not sure what is the preferred method in the programming world. As I mentioned, I'm very much a beginner, but noticed the difference in these two items and just want to know what the norm is as I can see the different, but don't know the practical, real world application of either approach.
Thanks.
String[][] capitals ={ {"Alabama", "Montgomery"},{"Alaska", "Juneau"},{"Arizona", "Phoenix"},{"Arkansas", "Little Rock"}, {"California", "Sacramento"}, {"Colorado", "Denver"}, {"Connecticut", "Hartford"}, {"Delaware", "Dover"}, {"Florida", "Tallahassee"},{"Georgia", "Atlanta"}, {"Hawaii", "Honolulu"},{"Idaho", "Boise"},{"Illinois", "Springfield"},{"Maryland", "Annapolis"},{"Minnesota", "Saint Paul"}, {"Iowa", "Des Moines"}, {"Maine", "Augusta"}, {"Kentucky", "Frankfort"}, {"Indiana", "Indianapolis"},{"Kansas", "Topeka"},{"Louisiana", "Baton Rouge"},{"Oregon", "Salem"}, {"Oklahoma", "Oklahoma City"},{"Ohio", "Columbus"},{"North Dakota", "Bismark"},{"New York", "Albany"},{"New Mexico", "Santa Fe"},{"New Jersey", "Trenton"}, {"New Hampshire", "Concord"},{"Nevada", "Carson City"},{"Nebraska", "Lincoln"},{"Montana", "Helena"},{"North Carolina", "Raleigh"},{"Missouri", "Jefferson City"}, {"Mississippi", "Jackson"}, {"Massachusetts", "Boston"}, {"Michigan", "Lansing"},{"Pennsylvania", "Harrisburg"},{"Rhode Island", "Providence"}, {"South Carolina", "Columbia"},{"South Dakota", "Pierre"}, {"Tennessee", "Nashville"},{"Texas", "Austin"},{"Utah", "Salt Lake City"}, {"Vermont", "Montpelier"},{"Virginia", "Richmond"},{"Washington", "Olympia"},{"West Virginia", "Charleston"},{"Wisconsin", "Madison"}, {"Wyoming", "Cheyenne"} };
String[][] capitalCities = { {"Alabama", "Alaska", "Arizona", "Arkansas", "California", "Colorado", "Connecticut", "Delaware", "Florida", "Georgia", "Hawaii", "Idaho", "Illinois", "Indiana", "Iowa", "Kansas", "Kentucky", "Louisiana", "Maine", "Maryland", "Massachusetts", "Michigan", "Minnesota", "Mississippi", "Missouri", "Montana", "Nebraska", "Nevada", "New Hampshire", "New Jersey", "New Mexico", "New York", "North Carolina", "North Dakota", "Ohio", "Oklahoma", "Oregon", "Pennsylvania", "Rhode Island", "South Carolina", "South Dakota", "Tennessee", "Texas", "Utah", "Vermont", "Virginia", "Washington", "West Virginia", "Wisconsin", "Wyoming"}, {"Montgomery", "Juneau", "Phoenix", "Little Rock", "Sacramento", "Denver", "Hartford", "Dover", "Tallahassee", "Atlanta", "Honolulu", "Boise", "Springfield", "Indianapolis", "Des Moines", "Topeka", "Frankfort", "Baton Rouge", "Augusta", "Annapolis", "Boston", "Lansing", "Saint Paul", "Jackson", "Jefferson City", "Helena", "Lincoln", "Carson City", "Concord", "Trenton", "Santa Fe", "Albany", "Raleigh", "Bismarck", "Columbus", "Oklahoma City", "Salem", "Harrisburg", "Providence", "Columbia", "Pierre", "Nashville", "Austin", "Salt Lake City", "Montpelier", "Richmond", "Olympia", "Charleston", "Madison", "Cheyenne"} };