Message from @Jacob

Discord ID: 500186049079934987


2018-10-12 05:52:32 UTC  

I don't know

2018-10-12 05:53:08 UTC  
2018-10-12 05:54:06 UTC  

@Jacob
line 4
```java
private Object data; //Assume data implemented Comparable
```

2018-10-12 05:54:23 UTC  

OK... you can assume that, but Java is going to want that declared somewhere

2018-10-12 05:54:31 UTC  

or it will refuse to compile

2018-10-12 05:54:44 UTC  

I think he really may want you to try/catch

2018-10-12 05:54:54 UTC  

God

2018-10-12 05:54:58 UTC  

I did this stuff like two years ago

2018-10-12 05:55:11 UTC  

I got a Java developer certificate when I graduated high school

2018-10-12 05:55:16 UTC  

and we did try catch and everything

2018-10-12 05:55:26 UTC  

```java
try {
your code;
}
catch Exception {
//leave empty lol
}
```

2018-10-12 05:55:27 UTC  

we also did Linked Lists I think

2018-10-12 05:55:40 UTC  

put that inside the method?

2018-10-12 05:55:52 UTC  

the entire method? @ThisIsChris

2018-10-12 05:56:34 UTC  

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

2018-10-12 05:56:49 UTC  

so put the entire loop inside it?

2018-10-12 05:58:28 UTC  

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

2018-10-12 06:00:16 UTC  

thanks

2018-10-12 06:00:21 UTC  

okay now I have a new exception

2018-10-12 06:00:43 UTC  

here is my new code

2018-10-12 06:00:47 UTC  

https://cdn.discordapp.com/attachments/352761432833523713/500186049079934986/StartupCode.zip

2018-10-12 06:01:06 UTC  

```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)
```

2018-10-12 06:01:10 UTC  
2018-10-12 06:02:12 UTC  

That's good, different errors now

2018-10-12 06:02:21 UTC  

Unfortunately it's 2am here so I have to get to bed

2018-10-12 06:02:39 UTC  

okay thanks for your help

2018-10-12 06:02:41 UTC  

good night

2018-10-12 06:02:52 UTC  

good night

2018-10-12 06:02:59 UTC  

by the way

2018-10-12 06:03:03 UTC  

for googling purposes

2018-10-12 06:03:34 UTC  

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"

2018-10-12 06:04:24 UTC  

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"

2018-10-12 06:04:59 UTC  

though googling "polymorphism in Java didn't present any helpful examples to your problem, maybe you'll have better luck

2018-10-12 06:05:01 UTC  

ok good night

2018-10-12 06:05:33 UTC  

thanks a lot

2018-10-12 06:05:35 UTC  

good night

2018-10-13 05:14:50 UTC  

@ThisIsChris When you run the Reddit script, do you also get a bunch of duplicate comments?

2018-10-13 05:15:01 UTC  

I'm trying to figure out how to fix it right now

2018-10-13 05:17:50 UTC  

you can keep a (global) list or set with the text of every comment you've printed before, so that if the text is already found in your list of already printed comments, then you don't print it.

2018-10-13 05:18:15 UTC  

There's a few slightly more optimized ways to do it, but that would be the laziest fastest to implement

2018-10-13 05:18:17 UTC  

hmm ya that's what I'm trying to do