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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T00:16:41+00:00 2026-06-11T00:16:41+00:00

Given a method such as: public void blit(int[] pos) { do stuff.. } Is

  • 0

Given a method such as:

public void blit(int[] pos) {
   do stuff..
}

Is there a way to pass in a list of arguments without first declaring them?

For instance, in Python, I could do something like:

def blit(pos):
   stuf...

blit([20,50])

I can simply pass in a list that created specifically in the argument list. To do the equivalent in Java, it seems I have to first declare the array, and only then can I pass it to the method.

int[] coordinates = {20,50};
blit(coordinates);

Which is not a huge deal, but it’d be handy if I could just do something like,

blit({20,50});

But that, of course, doesn’t work. I’ve also tried creating the array inside of the call like,

blit(new int[] = {20,40});

But again, no luck. So, perhaps a terrible question, but is there a way to pass lists of arguments to a method that mimics in part the behavior of Python?

  • 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-11T00:16:42+00:00Added an answer on June 11, 2026 at 12:16 am

    You could do it in two ways:

    blit(new int[] {20,40});
    

    Or declare your method with varargs:

    public void blit(int... pos) {}
    

    and call it like this:

    blit(20, 40);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

If I have a method such as: public void MyMethod(int arg1, string arg2) How
The following code gives a compile error: public void method(List<String> aList) {} public void
Given a method.. public ActionResult Method() { // program logic if(condition) { // external
Given the folowing, in pseudocode abstract public class Bug { private static int BREEDTIME;
I am using this method for encrypting a video file: public static void encryptToBinaryFile(String
I'm looking for a way to test if some given List is an unmodifiable
Given a set of functions, such as: template<class A1> Void Go(A1 a); template<class A1,
I'm looking for the best way to verify that a given method (the unit)
Given a Runnable object e.g. public class Test implements Runnable { @Override public void
Can I find out from which class a given method's implementation is inherited? e.g.

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.