• Post Reply Bookmark Topic Watch Topic
  • New Topic

Why boxing is preferred over var-args?  RSS feed

 
Samar Bir
Greenhorn
Posts: 23
IntelliJ IDE Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Everyone,

I know from JLS that widening is preferred over boxing and boxing is preferred over var-args.

I understand that, widening is legacy methodology and designers tend to keep it as a priority. What i fail to understand is why boxing is preferred over var-args. Here are my two concerns.

  • Why boxing is preferred over var-args?
  • How behind the scenes boxing and var-args is interpreted? How are var-args interpreted by the compiler? Is some sort of Array formed behind the scenes?


  • Can someone explain with an example?

    Thanks,
    Samar
     
    Joanne Neal
    Rancher
    Posts: 3742
    16
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Samar Bir wrote:I know from JLS that widening is preferred over boxing and boxing is preferred over var-args.

    Maybe there's some confusion over terminology here, but widening, boxing and var-args are different concepts. They are not interchangeable and therefore there's no question of preferring one over another.
    Perhaps you can give an example of these three concepts being used interchangeably.

    Samar Bir wrote:
  • Why boxing is preferred over var-args?

  • As I said, it's not because the two concepts are not interchangeable.

    Samar Bir wrote:How are var-args interpreted by the compiler? Is some sort of Array formed behind the scenes?[/list]

    Yes
     
    • Post Reply Bookmark Topic Watch Topic
    • New Topic
    Boost this thread!