Skip to content

Commit e648f35

Browse files
arrays
1 parent 0d4aff7 commit e648f35

18 files changed

+358
-0
lines changed

lectures/8-arrays/Arrays.pdf

1.23 MB
Binary file not shown.

lectures/8-arrays/code/.idea/.gitignore

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lectures/8-arrays/code/.idea/description.html

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lectures/8-arrays/code/.idea/encodings.xml

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lectures/8-arrays/code/.idea/misc.xml

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lectures/8-arrays/code/.idea/modules.xml

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lectures/8-arrays/code/.idea/project-template.xml

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lectures/8-arrays/code/.idea/vcs.xml

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lectures/8-arrays/code/code.iml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<module type="JAVA_MODULE" version="4">
3+
<component name="NewModuleRootManager" inherit-compiler-output="true">
4+
<exclude-output />
5+
<content url="file://$MODULE_DIR$">
6+
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
7+
</content>
8+
<orderEntry type="inheritedJdk" />
9+
<orderEntry type="sourceFolder" forTests="false" />
10+
</component>
11+
</module>
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
package com.kunal;
2+
3+
import java.util.ArrayList;
4+
import java.util.Scanner;
5+
6+
public class ArrayListExample {
7+
public static void main(String[] args) {
8+
Scanner in = new Scanner(System.in);
9+
// Syntax
10+
ArrayList<Integer> list = new ArrayList<>(5);
11+
12+
// list.add(67);
13+
// list.add(234);
14+
// list.add(654);
15+
// list.add(43);
16+
// list.add(654);
17+
// list.add(8765);
18+
19+
// System.out.println(list.contains(765432));
20+
// System.out.println(list);
21+
// list.set(0, 99);
22+
//
23+
// list.remove(2);
24+
//
25+
// System.out.println(list);
26+
27+
// input
28+
for (int i = 0; i < 5; i++) {
29+
list.add(in.nextInt());
30+
}
31+
32+
// get item at any index
33+
for (int i = 0; i < 5; i++) {
34+
System.out.println(list.get(i)); // pass index here, list[index] syntax will not work here
35+
}
36+
37+
System.out.println(list);
38+
39+
40+
41+
}
42+
}

0 commit comments

Comments
 (0)