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

python - django admin: changing the way a field (w/ relationship to another model) is submitted on a form so that it can be submitted multiple times -

go - serving up pdfs using golang -

ffmpeg - Using Live555 HTTP capacities as a server for signaling -