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
20278587
Commit
20278587
authored
Oct 09, 2024
by
Qazi Zain
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
List Code added in project
parent
994360e9
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
74 additions
and
3 deletions
+74
-3
.gitignore
src/.gitignore
+1
-0
CoustomArrayList.java
src/ListInterface/ArrayList/CoustomArrayList.java
+1
-2
Main.java
src/ListInterface/ArrayList/Main.java
+3
-1
CoustomLinkdList.java
src/ListInterface/LinkedList/CoustomLinkdList.java
+59
-0
Main.java
src/ListInterface/LinkedList/Main.java
+10
-0
No files found.
src/.gitignore
View file @
20278587
...
@@ -8,3 +8,4 @@ javaTraining.iml
...
@@ -8,3 +8,4 @@ javaTraining.iml
../out/production/javaTraining/ExceptionHandling/
../out/production/javaTraining/ExceptionHandling/
../out/production/javaTraining/Loops/
../out/production/javaTraining/Loops/
../out/production/javaTraining/Strings/
../out/production/javaTraining/Strings/
/src/out
\ No newline at end of file
src/ArrayList/CoustomArrayList.java
→
src/
ListInterface/
ArrayList/CoustomArrayList.java
View file @
20278587
package
ArrayList
;
package
ListInterface
.
ArrayList
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.Collection
;
import
java.util.Collections
;
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
class
CoustomArrayList
{
// It is a data structure it use, to store objects and size is not fixed like array.
...
...
src/ArrayList/Main.java
→
src/
ListInterface/
ArrayList/Main.java
View file @
20278587
package
ArrayList
;
package
ListInterface
.
ArrayList
;
import
ListInterface.ArrayList.CoustomArrayList
;
public
class
Main
{
public
class
Main
{
public
static
void
main
(
String
[]
args
)
{
public
static
void
main
(
String
[]
args
)
{
...
...
src/ListInterface/LinkedList/CoustomLinkdList.java
0 → 100644
View file @
20278587
package
ListInterface
.
LinkedList
;
import
java.util.*
;
public
class
CoustomLinkdList
{
LinkedList
<
Integer
>
obj
=
new
LinkedList
<>();
public
CoustomLinkdList
()
{
System
.
out
.
println
(
"Object is Created!"
);
}
public
void
LinkdList
()
{
// Adding in LinkedList
obj
.
add
(
3
);
obj
.
add
(
4
);
System
.
out
.
println
(
"LinkedList: "
+
obj
);
// Adding at a particular index
obj
.
add
(
1
,
7
);
obj
.
add
(
2
,
1
);
System
.
out
.
println
(
"LinkedList after adding at specific index: "
+
obj
);
// Adding elements at the first and last position
obj
.
addFirst
(
10
);
obj
.
addLast
(
20
);
System
.
out
.
println
(
"LinkedList after adding first and last: "
+
obj
);
// Removing elements
obj
.
remove
(
2
);
// Removes element at index 2
System
.
out
.
println
(
"LinkedList after removal at index 2: "
+
obj
);
obj
.
removeFirst
();
// Removes the first element
obj
.
removeLast
();
// Removes the last element
System
.
out
.
println
(
"LinkedList after removing first and last: "
+
obj
);
// Accessing elements
int
firstElement
=
obj
.
getFirst
();
int
lastElement
=
obj
.
getLast
();
System
.
out
.
println
(
"First element: "
+
firstElement
);
System
.
out
.
println
(
"Last element: "
+
lastElement
);
System
.
out
.
println
(
"Element at index 1: "
+
obj
.
get
(
1
));
// Checking if the list contains an element
boolean
contains7
=
obj
.
contains
(
7
);
System
.
out
.
println
(
"Contains 7? "
+
contains7
);
// Getting the size of the list
int
size
=
obj
.
size
();
System
.
out
.
println
(
"Size of LinkedList: "
+
size
);
// Clearing the list
obj
.
clear
();
System
.
out
.
println
(
"LinkedList after clearing: "
+
obj
);
// Re-adding elements after clearing
obj
.
add
(
50
);
obj
.
add
(
60
);
System
.
out
.
println
(
"LinkedList after re-adding elements: "
+
obj
);
}
}
src/ListInterface/LinkedList/Main.java
0 → 100644
View file @
20278587
package
ListInterface
.
LinkedList
;
public
class
Main
{
public
static
void
main
(
String
[]
args
)
{
CoustomLinkdList
obj
=
new
CoustomLinkdList
();
obj
.
LinkdList
();
}
}
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