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 7008863
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T21:47:24+00:00 2026-05-27T21:47:24+00:00

Recently I came across an API and it was using some Parameter void doSomething(final

  • 0

Recently I came across an API and it was using some Parameter

void doSomething(final String... olah) {
}

I never have seen something like that.

I have a List<String> now and I want to call that function with my list of string. How can I achieve that?

  • 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-05-27T21:47:25+00:00Added an answer on May 27, 2026 at 9:47 pm

    Welcome to modern Java. That syntax is called varargs in Java.

    http://docs.oracle.com/javase/1.5.0/docs/guide/language/varargs.html

    You can think of it like

    void doSomething(final String[] olaf) {
    
    }
    

    The only difference is that as the name suggests, it is Variable Length Arguments. You can invoke it with 0 to any number or arguments. Thus, doSomething("foo"), doSomething("foo", "bar"), doSomething("foo", "bar", "baz") are all supported.

    In order to invoke this method with a List argument though, you’ll have to first convert the list into a String[].

    Something like this will do:

    List<String> myList; // Hope you're acquainted with generics?
    
    doSomething(myList.toArray(new String[myList.size()]));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I recently came across a situation where I have to do some actions when
I recently came across this in some code - basically someone trying to create
I recently came across a great data structures book, Data Structures Using C (c)
I recently came across a question somewhere: Suppose you have an array of 1001
I recently came across some Java code that simply put some strings into a
I recently came across a web page using the font ff-tisa-web-pro-1 (specified in their
I recently came across some weird looking class that had three constructors: class Class
I've recently been working with a simple Twitter API for PHP and came across
I recently came across a coding standard claiming that you should never use public
I recently came across a requirement in creating an API for an existing web

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.