Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
J
Java. training
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Qazi Zain
Java. training
Commits
135278c4
Commit
135278c4
authored
9 months ago
by
Qazi Zain
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Array List Added
parent
858c6fe7
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
93 additions
and
0 deletions
+93
-0
.gitignore
src/.gitignore
+10
-0
CoustomArrayList.java
src/ArrayList/CoustomArrayList.java
+73
-0
Main.java
src/ArrayList/Main.java
+10
-0
No files found.
src/.gitignore
0 → 100644
View file @
135278c4
/src/.idea
/src/javaTraining.iml
out/
javaTraining.iml
../out/production/javaTraining/Arrays/
../out/production/javaTraining/BankManagementSystem/
../out/production/javaTraining/Connditional_Statements/
../out/production/javaTraining/ExceptionHandling/
../out/production/javaTraining/Loops/
../out/production/javaTraining/Strings/
This diff is collapsed.
Click to expand it.
src/ArrayList/CoustomArrayList.java
0 → 100644
View file @
135278c4
package
ArrayList
;
import
java.util.ArrayList
;
import
java.util.Collection
;
import
java.util.Collections
;
public
class
CoustomArrayList
{
// It is a data structure it use, to store objects and size is not fixed like array.
public
ArrayList
<
Integer
>
list
=
new
ArrayList
<>();
// list is an object of array list. (Integer is a wrapper class of int holds int value as object)
CoustomArrayList
()
{
System
.
out
.
println
(
"Object is created"
);
}
void
arrayListFunctions
()
{
list
.
add
(
2
);
list
.
add
(
3
);
list
.
add
(
4
);
list
.
add
(
7
);
list
.
add
(
6
);
list
.
add
(
7
);
list
.
add
(
8
);
System
.
out
.
println
(
"Here is your list: ["
+
list
+
"]"
);
int
element
=
list
.
get
(
2
);
System
.
out
.
println
(
"printing element on index 2 is:"
+
element
);
// adding values on any particular index.
list
.
add
(
3
,
5
);
System
.
out
.
println
(
"Here is your list: ["
+
list
+
"]"
);
// set element present on any particular index.
list
.
set
(
4
,
05
);
System
.
out
.
println
(
"Here is your list: ["
+
list
+
"]"
);
//delete elements from list.
list
.
remove
(
4
);
System
.
out
.
println
(
"Here is your list: ["
+
list
+
"]"
);
// size
int
size
=
list
.
size
();
System
.
out
.
println
(
size
);
list
.
add
(
0
,
12
);
list
.
add
(
2
,
11
);
list
.
add
(
3
,
9
);
System
.
out
.
println
(
"Here is your list: ["
+
list
+
"]"
);
// sorting assending.
Collections
.
sort
(
list
);
System
.
out
.
println
(
"Here is your list: ["
+
list
+
"]"
);
//printing array using loop
for
(
int
i
=
0
;
i
<
list
.
size
();
i
++)
{
System
.
out
.
println
(
list
.
get
(
i
));
}
}
}
This diff is collapsed.
Click to expand it.
src/ArrayList/Main.java
0 → 100644
View file @
135278c4
package
ArrayList
;
public
class
Main
{
public
static
void
main
(
String
[]
args
)
{
CoustomArrayList
obj
=
new
CoustomArrayList
();
obj
.
arrayListFunctions
();
}
}
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment