Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Overloading Methods using Widening, Boxing, Var-args

 
Yin Stadfield
Ranch Hand
Posts: 58
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all!

Can someone explain each of these for me, example will also be appreciated:

- Primitive widening uses the "smallest" method argument possible. ???
- Used individually, boxing and var-args are compatible with overloading. ???
- You CANNOT widen from one wrapper type to another. - I got it, you can't widen Integer to Long, Byte to Integer, etc, because they're objects (unlike primitives) and do not extend each other.
- You CANNOT widen and then box. - I got it. Say there's a byte 5, you can't pass it on Integer, hoping that byte will be widen to int and then will box to Integer, it doesn't work that way.
- You can box and then widen. - I got it. You can convert byte 5 to Byte, and then widen Byte to Object since all classes extends Object. If there's more to it, please let me know.
- You can combine var-args with either widening or boxing. ???

Thanks!
 
Himai Minh
Ranch Hand
Posts: 1328
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Primitive widening uses the smallest method argument:


You can combine var-args with widening or boxing:


 
Dan Drillich
Ranch Hand
Posts: 1183
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Used individually, boxing and varargs are compatible with overloading can assist.

Regards,
Dan
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic