Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
J
JAVA Learning
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
VIGNESH VIJAYAKUMAR
JAVA Learning
Commits
cbbb4ffc
Commit
cbbb4ffc
authored
9 months ago
by
VIGNESH VIJAYAKUMAR
Browse files
Options
Downloads
Patches
Plain Diff
Upload New File
parent
22ba4a5c
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Core Java/ArrayL.java
+28
-0
28 additions, 0 deletions
Core Java/ArrayL.java
with
28 additions
and
0 deletions
Core Java/ArrayL.java
0 → 100644
+
28
−
0
View file @
cbbb4ffc
import
java.util.ArrayList
;
import
java.util.Collections
;
public
class
ArrayLinked
{
public
static
void
main
(
String
[]
args
){
String
[]
cc
=
{
"volvo"
,
"BMW"
};
System
.
out
.
println
(
cc
);
//this print doesn't work properly
for
(
String
i:
cc
){
System
.
out
.
println
(
i
);
}
ArrayList
<
String
>
cars
=
new
ArrayList
<
String
>();
cars
.
add
(
"Volvo"
);
cars
.
add
(
"Audi"
);
cars
.
add
(
"Lamborgini"
);
System
.
out
.
println
(
cars
);
//this print as like array [elements....]
Collections
.
sort
(
cars
);
System
.
out
.
println
(
"After sorting : "
+
cars
);
System
.
out
.
println
(
"at index 1: "
+
cars
.
get
(
1
));
//return 1st index element
System
.
out
.
println
(
"replace index \"1\" with Ferrari"
);
cars
.
set
(
1
,
"Ferrari"
);
System
.
out
.
println
(
cars
);
System
.
out
.
println
(
"Before remove : "
+
cars
.
size
());
cars
.
remove
(
1
);
//remove element
System
.
out
.
println
(
"After remove : "
+
cars
.
size
());
System
.
out
.
println
(
cars
);
cars
.
clear
();
System
.
out
.
println
(
"After cars.clear():"
+
cars
);
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment