Was 1900 a leap year and does every minute have 60 seconds?
In Java we have a new API for Date and Time since Java SE 8. Before that, there was already an API with mutable dates and fore some reason there was a date just for SQL.
Since many were not happy with it there was Joda-Time, which later became the basis for JSR-310 and is now found in the package “java.time”.
Category: Misconceptions
Common misconceptions on programming and computer science in general.
I try answerings questions in a facebook group and often stumble over the same misconceptions. These are merely my thoughts on the topic and not a substitution for a proper text book. A good book can sometimes leave out certain details but it would not lead you to a complete misunderstanding of the topic.
Misnomer: static Keyword
The keyword static is arguably a bad choice or naming.
If you look up “static” in a dictionary you find many meanings, none of which explains its use in programming languages. So why is it used in Java, and how is it misunderstood? Continue reading “Misnomer: static Keyword”
Set-theoretic explanation of IEEE 754
Why is 0.1+0.2 not equal to 0.3?
The IEEE Standard for Floating-Point Arithmetic is confusing for beginners. Here I try to give an alternative explanation. It’s not my goal to make it easy. It simply isn’t easy. But this might help understand some aspects of floating point arithmetic.
Continue reading “Set-theoretic explanation of IEEE 754”Encapsulation
In my blog I write about misconceptions. Encapsulation is something you learn when you study Java and OOP. But it seems that most books fail to truly explain the problems you want to solve with it and those you get by using it. Often it’s just a short chapter or even just a small part about the important concepts of OOP. This is leading to misconceptions and poor understanding of OOP.
(Note: I wrote this before the release of Java 10. Expect that some things are somewhat outdated.)
Double Checked Locking in Java
You may wonder if double checked locking (DCL) works in Java. It does and it doesn’t. I explain why. Continue reading “Double Checked Locking in Java”
What are References in Java?
So Java has references. But what about pointers and pass-by-reference? References in Java are different to PHP, C# and other languages. And this can cause some confusion. Continue reading “What are References in Java?”
Java knows no Constants
Java (both the language and the JVM) are not aware of constants. To reduce confusion it’s better to not use the term “constant” in Java code, unless it’s actually a universal constant. Continue reading “Java knows no Constants”
Java is not slow
A language can’t be slow. Or how fast do you think English is?
And modern JVMs are highly optimized. Continue reading “Java is not slow”
Dos and Don’ts
Here’s some advice to all who have just begun learning Java. This also serves as an overview to my blog, where I write about all kinds of misconceptions and common problems with programming in Java. Continue reading “Dos and Don’ts”
Misconceptions about the “extends” Keyword
Some Mammals can fly. Dog extends Mammal, but it can’t fly. The term “extends” leads to some misconceptions. Continue reading “Misconceptions about the “extends” Keyword”