12/26/2022
This year I had the ambition to actually use Java for Advent of Code (AOC). And needless to say, I got pretty far before falling down because of time issues and trying to solve it in a good way. What I actually should have done is use the quick and dirty way where possible so that I didnโt lose a lot of time.
But I wanted to learn new things about Java and forcing myself to make a better solution worked out for the easier puzzles thus far. For this year because Java 17 was out I decided it was maybe good to try it out and find newer features.
I wrote down most things I learned in the README.md file of the project, but here is a quick summary:
You can make an easy List without the use of a collector now:
Example:
// Java 17
List<String> cookiesToBuy = groceries.filter(g -> g.name.includes("Cookies")).toList();
// Java 11
List<String> cookiesToBuy = groceries.filter(g -> g.name.includes("Cookies")).collect(Collectors.toList());
I also learned that you can make 3D arrays in Java. I knew this from my Gamedevelopment experience but I didnโt know the option existed in Java as well because I never had the need to use it. So I was making my own data structure before with classes which uses a lot more memory. This way when loading a lot of objects I donโt need to have more than 128GB to run the puzzle ๐
Example:
int size = 10;
String[][][] = new String[size][size][size];