I have a few questions on NumberFormat that I've come up with while reading Head First
Java.
NumberFormat form = NumberFormat.getNumberInstance();
num = form.format(i);
This line of code is creating a NumberFormat object with the reference value of form. It doesn't use the "new" operator, but calls a static final method on an abstract class to get one. My problem is this. The method returns a NumberFormat object which I then call the format instance method on. Is that legal? Calling an instance method on an abstract reference?
It just bothers me..... Can anyone clear this up? I've been using this stuff for awhile, but had never really thought about what was going on behind the scenes. If NumberFormat wasn't abstract I would be ok, but calling an instance method on an abstract class (which I thought you couldn't instantiate) seems wrong.
Thanks...
Erik