Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8037499
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T02:56:49+00:00 2026-06-05T02:56:49+00:00

I am looking for a relevant portion of the Java Language Specification (JLS) which

  • 0

I am looking for a relevant portion of the Java Language Specification (JLS) which describes the behaviour when invoking a variable arity (vararg) method.

Consider the method:

public static void printVarArgs(String... args) {
    System.out.println(Arrays.toString(args));
}

If I invoke the method like so:

printVarArgs();

The output will look like: [] because the omission of args at the call site has been converted into an empty array in the printVarArgs method.

I am looking for the point of the JLS which defines this behaviour. The closest I have found is 15.12.4.2 Evaluate Arguments, but it doesn’t give this example, and I’m not sure if this case is actually covered by the formal/mathematical description.

Which part of the JLS describes the automatic creation of an empty array when a vararg is omitted?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T02:56:52+00:00Added an answer on June 5, 2026 at 2:56 am

    The text of that JLS section says:

    If the method being invoked is a variable arity method (§8.4.1) m, it necessarily has n > 0 formal parameters. The final formal parameter of m necessarily has type T[] for some T, and m is necessarily being invoked with k >= 0 actual argument expressions.

    If m is being invoked with kn actual argument expressions, or, if m is being invoked with k != n actual argument expressions and the type of the kth argument expression is not assignment compatible with T[], then the argument list (e1, ... , en-1, en, ...ek) is evaluated as if it were written as (e1, ..., en-1, new T[]{en, ..., ek}).

    In the case you are talking about, there are k == n - 1 formal arguments, so en, ..., ek is an empty sequence, and that means the argument is evaluated as if it was (e1, ..., en-1, new T[]{}).

    In other words, the behaviour is specified in the section you were looking at.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm looking for java based tools for extracting relevant tags from a given article.
Looking at the output of this particular method is confusing to me. I'm trying
I'm looking for a diff equivalent written in JavaScript that only returns/prints relevant lines.
I'm looking into building an IM-type application using Java stack (for the server at
I'm looking for resources and book which one can use to get started with
Looking at the Windows Runtime reference at the Microsoft site the only relevant collection
The most relevant question here on StackOverflow was this , which still doesn't answer
I tried looking this up, but could not find anything relevant, but I think
I'm looking to understand why Java designers chose to implement function declarations this way.
Just looking for the relevant documentation. An example is not necessary, but would be

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.