File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Unboxing and widening ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Unboxing and widening ?" Watch "Unboxing and widening ?" New topic
Author

Unboxing and widening ?

Mahtab Alam
Ranch Hand

Joined: Mar 28, 2012
Posts: 283

class Cast
{
public static void main(String args[])
{
Short s=new Short((short)10);
show(s);
}

static void show(int i)
{
System.out.println("Great");
}
}

This works so it means that Short is first unboxed to short which is then widened to int

Oracle Java Programmer , Oracle SQL Expert , Oracle Java Web Component Developer
Zhenyi Luo
Ranch Hand

Joined: Sep 03, 2012
Posts: 33
Mahtab Alam wrote:class Cast
{
public static void main(String args[])
{
Short s=new Short((short)10);
show(s);
}

static void show(int i)
{
System.out.println("Great");
}
}

This works so it means that Short is first unboxed to short which is then widened to int


That's correct.
 
 
subject: Unboxing and widening ?