-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
51 additions
and
1 deletion.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<module type="JAVA_MODULE" version="4"> | ||
<component name="NewModuleRootManager"> | ||
<output url="file://$MODULE_DIR$/out/production/" /> | ||
<output-test url="file://$MODULE_DIR$/../out/test/07-2DArrayList" /> | ||
<exclude-output /> | ||
<content url="file://$MODULE_DIR$"> | ||
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" /> | ||
</content> | ||
<orderEntry type="inheritedJdk" /> | ||
<orderEntry type="sourceFolder" forTests="false" /> | ||
</component> | ||
</module> |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import java.util.*; | ||
public class Main { | ||
public static void main(String[] args) { | ||
|
||
//2D ArrayList - a dynamic list of lists | ||
//You can change the size of these lists during runtime | ||
ArrayList<String> bakeryList = new ArrayList(); | ||
bakeryList.add("flour"); | ||
bakeryList.add("butter"); | ||
bakeryList.add("eggs"); | ||
|
||
ArrayList<String> produceList = new ArrayList(); | ||
produceList.add("tomatoes"); | ||
produceList.add("cucumbers"); | ||
produceList.add("zucchini"); | ||
|
||
ArrayList<String> drinkList = new ArrayList(); | ||
drinkList.add("coca-cola"); | ||
drinkList.add("coffee"); | ||
|
||
//Adds all the Lists to one Lists | ||
//Note: It's more organized | ||
ArrayList<ArrayList<String>> groceryList = new ArrayList(); | ||
groceryList.add(bakeryList); | ||
groceryList.add(produceList); | ||
groceryList.add(drinkList); | ||
|
||
//System.out.println(bakeryList.get(0)); | ||
//System.out.println(drinkList); | ||
System.out.println(groceryList); | ||
//Get one List from the 2D ArrayList | ||
System.out.println(groceryList.get(0)); | ||
//Get certain element/value from one List inside 2D ArrayList | ||
System.out.println(groceryList.get(2).get(0)); | ||
} | ||
} |