- Your implementation does not allow for an empty list.
Your implementation does not allow for an empty list.
It's a bit odd to only have the constructor which takes a node value.
You should probably implement the
List
interface.You should look into generics instead of hard-coding your list to only take
int
s.It looks like from looking at
insert()
that you are trying to create an ordered linked list. However,append()
does not. (If you really want to define an ordered linked list, you can still use generics, but you'll have to use types which are children ofComparable
).In
insert()
anddelete()
you have someif
-conditions followed by awhile
-loop. My guess is that they can be merged in a singlewhile
-loop. I was lazy and haven't tried doing it, so it might not be true.
1.1) It's a bit odd to only have the constructor which takes a node value.
You should probably implement the
List
interface.You should look into generics instead of hard-coding your list to only take
int
s.It looks like from looking at
insert()
that you are trying to create an ordered linked list. However,append()
does not. (If you really want to define an ordered linked list, you can still use generics, but you'll have to use types which are children ofComparable
).In
insert()
anddelete()
you have someif
-conditions followed by awhile
-loop. My guess is that they can be merged in a singlewhile
-loop. I was lazy and haven't tried doing it, so it might not be true.