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; 

auto boxing.

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

Popular posts from this blog

networking - Vagrant-provisioned VirtualBox VM is not reachable from Ubuntu host -

c# - ASP.NET Core - There is already an object named 'AspNetRoles' in the database -

android - IllegalStateException: Cannot call this method while RecyclerView is computing a layout or scrolling -