0
is this an accurate way to check if linked list is full? using java.
public boolean isFull() { Node temp; temp = head; if (temp == head) { temp= null; return false; }else { return true; } }
2 Respostas
0
Didn't know that LinkedList or any
other collection in java can be full. As I know they are resized by them self if their capacity is filled until some percent of their current capacity.
About your method - it will return always false since temp = head.
Maybe I didn't understand your question correctly, please explain more, if my answer is not what you were looking for.
0
mya
Do you mean that you want to check if your list contains objects or not?
Every list has a size. Size = 0 --> empty list.
if(YourLinkedList.size () > 0){
return true; //there are objects inside your list
}
return false; //empty list