Number in java how it work without a subclass? -
i want know why result of code:
number x = 3; system.out.println(x.intvalue()); system.out.println(x.doublevalue());
generates
3
3.0
as number abstract class in java.
so when need use - use it's subclasses integer, double ...etc. want know how part of code works:
number x = 3;
so when
number x = 3;
that gets compiled
number x = new integer(3);
number in java how work without subclass?
that wrong assumption. number class have subclasses. if @ definition of integer class.
look @ definition of integer class
public final class integer extends number
it sublcass of number gets compiled fine.
Comments
Post a Comment