wood burning stoves 2.0*
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 Murach's Java Servlets and JSP this week in the Servlets 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: 222

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
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Unboxing and widening ?
 
Similar Threads
Short initialize
Method calling
Regarding main()
Method overloading
short assignment.