r/learnprogramming • u/tempyreddity • Dec 03 '15
PSA: Don't use the Java standard library
Hey guys,
So I was working through an advent of code challenge, and it looks like apparently there are issues that can arise from the java standard library, in particular hashset. See here: https://www.reddit.com/r/adventofcode/comments/3v8roh/day_3_solutions/cxlfuvp?context=3
I'm a newbie so I thought others would want to know about this before trying to figure out why their programs aren't working. Write your own classes!
0
Upvotes
View all comments
Show parent comment
6
u/nutrecht Dec 03 '15
Multiple users told you exactly what you did wrong in your code. If you check mine you'll see that I'm using HashSet with my own point class. One that is immutable on purpose. The problem is very simply that you're not creating new instances of Point but instead modify the value of the existing point.