Message from @Paragram Slide - AZ
Discord ID: 495338090567827458
linked list
huh I get a null pointer exception from somewhere else, too
```java
------------------testAddLast()----
Exception in thread "main" java.lang.NullPointerException
at MyLinkedList$ListNode.access$2(MyLinkedList.java:11)
at MyLinkedList.add(MyLinkedList.java:205)
at MyLinkedListTester.testAddLast(MyLinkedListTester.java:42)
at MyLinkedListTester.main(MyLinkedListTester.java:214)
```
```java
public static void testAddLast() { //passed
System.out.println("------------------testAddLast()----");
init();
list3.add("A");
System.out.println(list3);
list3.add("B");
System.out.println(list3);
list3.add(null);
System.out.println(list3);
list3.add("C");
System.out.println(list3);
drawLine();
}
```
```java
//Add the object e to the end of this list.
// it returns true, after e is successfully added.
public boolean add(Object e) {
ListNode newNode = new ListNode(e);
newNode.next = null;
get(this.size - 1).next = newNode;
this.size++;
return true;
}
```
any glaring problems here?
that get() could return null
hmmm
any ideas on how to fix that?
after init()
how many nodes in list3
println after init()
4
what is size
should be 4
I see
list3.add("C") will throw
because last node was null
and when you get it... and attempt to set next
the data was null, not the node itself I think
it must be the size then
get(this.size - 1) is returning null
```
ListNode last = get(this.size - 1);
if (last != null) {
last.next = newNode;
++this.size;
return true;
}
return false;
```
thanks
this would only happen adding first node to list I would think
what is this class?
data structures?
or Java class?
Data Structures
I actually have a Java developer certificate but it was a long time ago so I have to relearn everything
Got it same time as I graduated high school
when I took that class we used C
1999 😉
Java was its own class back then - the OOP class
I had to take a 3 part Java series to get into this class
It was part of my certificate
nice
it's a good line of work
I need help factoring a math problem @here
-x^2 + 5x + 14