You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: _posts/collections/arraylist/2021-11-27-add-element-in-arraylist.md
+10-10Lines changed: 10 additions & 10 deletions
Original file line number
Diff line number
Diff line change
@@ -1,13 +1,13 @@
1
-
---
1
+
---
2
2
layout: post
3
3
title: "How To Add An Element To ArrayList In Java?"
4
4
author: gaurav
5
5
categories: [Collections, ArrayList]
6
6
toc: true
7
-
description: "In this article, we will see how to add element in ArrayList. Also, we will see how can we add an element at particular index in ArrayList."
7
+
description: "In this article, we will see how to add an element in ArrayList. Also, we will see how we can add an element at a particular index in ArrayList."
8
8
---
9
9
10
-
In this article, we will see how to add an element in [ArrayList](https://coderolls.com/arraylist-in-java/). Also, we will see how can we add an element at particular index in ArrayList.
10
+
In this article, we will see how to add an element in [ArrayList](https://coderolls.com/arraylist-in-java/). Also, we will see how we can add an element at a particular index in ArrayList.
11
11
12
12
## Introduction
13
13
@@ -29,7 +29,7 @@ This method appends the specified element `e` to the end of the list.
29
29
30
30
This method returns `true` if the element is added to the list otherwise, it returns `false`.
31
31
32
-
Let's see a java program to add an element to the list using the above method.
32
+
Let's see a Java program to add an element to the list using the above method.
33
33
34
34
```java
35
35
@@ -83,7 +83,7 @@ This method adds the specified element `element` at the specified index `index`.
83
83
84
84
This method has a return type as `void` so, it will not return anything.
85
85
86
-
Below, we will see a java program to add an element at the specified index in ArrayList.
86
+
Below, we will see a Java program to add an element at the specified index in ArrayList.
87
87
88
88
```java
89
89
importjava.util.ArrayList;
@@ -103,7 +103,7 @@ public class ArrayListAddExample {
//adding elements to the arrayList using normal add method
106
+
//adding elements to the arrayList using the normal add method
107
107
arrayList.add("Gaurav");
108
108
arrayList.add("Shyam");
109
109
@@ -125,12 +125,12 @@ Output:
125
125
126
126
## Conclusion
127
127
128
-
We can add element to the [ArrayList](https://coderolls.com/arraylist-in-java/) using `add()` method in two ways.
128
+
We can add an element to the [ArrayList](https://coderolls.com/arraylist-in-java/) using the`add()` method in two ways.
129
129
1.`add(E e)` - It will add an element to the end of the ArrayList
130
-
2.`add(int index, E element)`- This method will add an element at the specified index
130
+
2.`add(int index, E element)`- This method will add an element to the specified index
131
131
132
132
---
133
133
134
-
The example java programs given in the above tutorial can be found at [this GitHub Repository](https://github.com/coderolls/blogpost-coding-examples/tree/main/collections/arraylist/add-element-in-arraylist).
134
+
The example Java programs given in the above tutorial can be found at [this GitHub Repository](https://github.com/coderolls/blogpost-coding-examples/tree/main/collections/arraylist/add-element-in-arraylist).
135
135
136
-
If you know any other ways, you a can write a comment below.
136
+
If you know of any other ways, you can write a comment below.
0 commit comments