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; } }

15th Feb 2019, 6:05 PM
mya
mya - avatar
2 Answers
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.
15th Feb 2019, 6:25 PM
vlada
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
15th Feb 2019, 10:17 PM
Denise Roßberg
Denise Roßberg - avatar