Message from @ThisIsChris
Discord ID: 500184988935913473
maybe I could cast the object?
the tester class only uses characters
@Jacob Cast it as Comparable?
or maybe as a char
or integer if that's possible
I don't know
@Jacob
line 4
```java
private Object data; //Assume data implemented Comparable
```
OK... you can assume that, but Java is going to want that declared somewhere
or it will refuse to compile
I think he really may want you to try/catch
God
I did this stuff like two years ago
I got a Java developer certificate when I graduated high school
and we did try catch and everything
```java
try {
your code;
}
catch Exception {
//leave empty lol
}
```
we also did Linked Lists I think
put that inside the method?
the entire method? @ThisIsChris
I'd put the `try` at line 148, just before the while loop, don't want that thing to go on catching exceptions forever waiting for the loop to break
so put the entire loop inside it?
so
```java
try {
//lines 149-163, the whole outer while loop, until just before the function ends
}
catch Exception {
//leave blank because we're supposed to assume nothing will happen
}
//then exit the function
}
``` @Jacob
thanks
okay now I have a new exception
here is my new code
```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)
```
That's good, different errors now
Unfortunately it's 2am here so I have to get to bed
okay thanks for your help
good night
good night
by the way
for googling purposes
what I suggested with "try to see if it works, catch an exception if it doesn't" is called "duck typing" so for more info you can google "duck typing in java"
The idea of a function that can take in anything that implements a function (like the sort function that works on any node data that implements a `compareTo` function) is called "polymorphism"
though googling "polymorphism in Java didn't present any helpful examples to your problem, maybe you'll have better luck
ok good night
thanks a lot