Skip to content

Commit

Permalink
Added ArrayList
Browse files Browse the repository at this point in the history
  • Loading branch information
NMKrastev committed Jun 30, 2022
1 parent b40aa63 commit 4f76b25
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 1 deletion.
1 change: 1 addition & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion 05-toStringMethod/05-toStringMethod.iml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager">
<output url="file://$MODULE_DIR$/out/production/" />
<output url="file://$MODULE_DIR$/out/production" />
<output-test url="file://$MODULE_DIR$/../out/test/05-toStringMethod" />
<exclude-output />
<content url="file://$MODULE_DIR$">
Expand Down
13 changes: 13 additions & 0 deletions 06-ArrayList/06-ArrayList.iml
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/06-ArrayList" />
<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 added 06-ArrayList/out/production/Main.class
Binary file not shown.
28 changes: 28 additions & 0 deletions 06-ArrayList/src/Main.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import java.util.ArrayList;

public class Main {
public static void main(String[] args) {

//ArrayList - a resizable array.
//Elements can be added and removed after compilation phase
//Stores reference data types

ArrayList<String> food = new ArrayList<String>();

food.add("Chicken breasts");
food.add("Olives");
food.add("Potatoes");

//Sets value to a certain index. It replaces Chicken breasts
food.set(0, "Pork");
//Removes value from certain index
food.remove(2);
//Clears ArrayList
food.clear();


for (int i = 0; i < food.size(); i++) {
System.out.println(food.get(i));
}
}
}

0 comments on commit 4f76b25

Please sign in to comment.