• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Tim Cooke
  • Paul Clapham
  • Jeanne Boyarsky
Sheriffs:
  • Ron McLeod
  • Frank Carver
  • Junilu Lacar
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Frits Walraven
  • fred rosenberger

Variable arguments

 
Ranch Hand
Posts: 83
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please programmers inthe house willyou bail meout please:
How do i accept values from a mian mnethod decleared like this:
public static void main(String... a){}
I'm i going to use array as it uused to be?

Juwonlo(pre scjp)
 
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes, the variable 'a' is an array of Strings, it works exactly the same as when you write:

public static void main(String[] a)
 
Juwonlo Ibigbami
Ranch Hand
Posts: 83
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Jesper,Thanks, but one more thing, what of if i have an overloaded method like this:
class X{
void getIt(int a){}
void getIt(int... a){}
}

will accept the value in the second getIt like an array?
 
Ranch Hand
Posts: 377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Juwonlo Ibigbami:
will accept the value in the second getIt like an array?

Try it.
 
Juwonlo Ibigbami
Ranch Hand
Posts: 83
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sorry, can anyone think of dynamically getting and sending some value (whos maximumlenghtyou dontknow)to send to the method:
-----------------------------------
void getIt(int... a){}
-------------------------------------
at runtime for a more dynamic implimentation situation?
Iamnot crazzy, thatmight not be the intention of sun for creating the var-args but.......

Juwonlo
 
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Juwonlo,

you probably need to reconstruct your question...
dynamically getting and sending some value (whos maximumlenghtyou dontknow)to send to the method ... because this does not make any sense.

cheers...
 
Do Re Mi Fa So La Tiny Ad
Garden Master Course kickstarter
https://coderanch.com/t/754577/Garden-Master-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic