If you want to show some animation, maybe for a simple java game, then you need to render a certain amount of frames per second. For a smooth animation you want 30 to 60 frames per second. But sometimes the needed calculations need a bit longer so the delay until the drawing of the next frame needs to be shorter. For this an animation loop is needed. I have implemented a very simple animation loop for Java 8+ that can be paused and started.
Java doesn’t provide tuples. Here are some ideas what you can do about it. Continue reading “Tuples in Java”
So in Java there are many kinds of methods. I probably won’t even list half of them but I try to explain how different methods can be.Continue reading “Types of Methods in Java”
There’s a lot of confusion about “functions” in Java. Java doesn’t really have them, but an object could represent a function so it kind of does have them. I try to explain the different meanings of “functions” in Java, other languages and in mathematics.Continue reading “Functions in Java”
Many things are outdated and better alternatives exist.
New is used to create new objects. But it’s used carelessly.Continue reading “Misconceptions about the new Operator”
In Java you can only reference final fields inside a closure. Here’s my solution*.Continue reading “Recursive Closures in Java”
Point 11 of the Joel Test asks: “Do new candidates write code during their interview?”
But how do you do that? I find most tips on the internet aren’t really helpful or realistic.
The given implementation for
hashCode is somewhat a mystery. Some misconceptions about it confuse students. I try to explain it. Continue reading “Misconceptions about Object.hashCode()”
Generics have one thing in common with regular expressions: Students think they are an easy to use tool but they just end up with code they do not understand and can’t maintain. Regular expressions can often be replaced by well written and documented code. But you can’t just replace generics. A student using collections with generic type parameters but not fully understanding the concept is still better than one using “raw” collections. And it’s often ok to use something just to get familiar with the idea before learning the theory. The downside is that many misconceptions emerge from this approach of teaching. In this post I try to explain some of the common misconceptions on generics in Java.Continue reading “Generics”