How to deal with variable length argument lists in java methods

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

How to deal with variable length argument lists in java methods

Dave Woodman

This is probably my brain failing to recall something, but…

 

Consider the following java (deconstructed to the minimum for brevity):-

 

import javax.swing.filechooser.*;

 

public class Testit {  

      FileNameExtensionFilter filter = new FileNameExtensionFilter("JPEG file", "jpg", "jpeg");

}

 

This is fine, and is, indeed, the canonical example. FileNameExtensionFilter can take a variable number of parameters, although one would consider two to be the minimum useful number…

 

As for the NetRexx that is equivalent to this:-

 

import javax.swing.filechooser.

 

class Testit public

      properties public

      filter =  FileNameExtensionFilter("JPEG file", "jpg", "jpeg")

 

This gives…

The constructor 'FileNameExtensionFilter(java.lang.String,java.lang.String,java.lang.String)' cannot be found in class 'javax.swing.filechooser.FileNameExtensionFilter'

 

Has my grey matter gone offline, or my intellect poisoned by expose to too many languages? Or is there a trick, or limitation?

 

                Dave.




This email is free from viruses and malware because avast! Antivirus protection is active.



_______________________________________________
Ibm-netrexx mailing list
[hidden email]
Online Archive : http://ibm-netrexx.215625.n3.nabble.com/

Reply | Threaded
Open this post in threaded view
|

Re: How to deal with variable length argument lists in java methods

Kermit Kiser
Java implements variable length parm lists by passing everything after the first parm as a string array. Try this syntax:

filter =  FileNameExtensionFilter("JPEG file", [String "jpg", "jpeg"])

-- Kermit

On 6/3/2014 5:00 AM, Dave Woodman wrote:

This is probably my brain failing to recall something, but…

 

Consider the following java (deconstructed to the minimum for brevity):-

 

import javax.swing.filechooser.*;

 

public class Testit {  

      FileNameExtensionFilter filter = new FileNameExtensionFilter("JPEG file", "jpg", "jpeg");

}

 

This is fine, and is, indeed, the canonical example. FileNameExtensionFilter can take a variable number of parameters, although one would consider two to be the minimum useful number…

 

As for the NetRexx that is equivalent to this:-

 

import javax.swing.filechooser.

 

class Testit public

      properties public

      filter =  FileNameExtensionFilter("JPEG file", "jpg", "jpeg")

 

This gives…

The constructor 'FileNameExtensionFilter(java.lang.String,java.lang.String,java.lang.String)' cannot be found in class 'javax.swing.filechooser.FileNameExtensionFilter'

 

Has my grey matter gone offline, or my intellect poisoned by expose to too many languages? Or is there a trick, or limitation?

 

                Dave.




This email is free from viruses and malware because avast! Antivirus protection is active.




_______________________________________________
Ibm-netrexx mailing list
[hidden email]
Online Archive : http://ibm-netrexx.215625.n3.nabble.com/



_______________________________________________
Ibm-netrexx mailing list
[hidden email]
Online Archive : http://ibm-netrexx.215625.n3.nabble.com/

Reply | Threaded
Open this post in threaded view
|

Re: How to deal with variable length argument lists in java methods

Dave Woodman

That would appear to have it covered – many thanks!

 

                Dave.

 

From: [hidden email] [mailto:[hidden email]] On Behalf Of Kermit Kiser
Sent: 03 June 2014 17:24
To: IBM Netrexx
Subject: Re: [Ibm-netrexx] How to deal with variable length argument lists in java methods

 

Java implements variable length parm lists by passing everything after the first parm as a string array. Try this syntax:

filter =  FileNameExtensionFilter("JPEG file", [String "jpg", "jpeg"])

-- Kermit

On 6/3/2014 5:00 AM, Dave Woodman wrote:

This is probably my brain failing to recall something, but…

 

Consider the following java (deconstructed to the minimum for brevity):-

 

import javax.swing.filechooser.*;

 

public class Testit {  

      FileNameExtensionFilter filter = new FileNameExtensionFilter("JPEG file", "jpg", "jpeg");

}

 

This is fine, and is, indeed, the canonical example. FileNameExtensionFilter can take a variable number of parameters, although one would consider two to be the minimum useful number…

 

As for the NetRexx that is equivalent to this:-

 

import javax.swing.filechooser.

 

class Testit public

      properties public

      filter =  FileNameExtensionFilter("JPEG file", "jpg", "jpeg")

 

This gives…

The constructor 'FileNameExtensionFilter(java.lang.String,java.lang.String,java.lang.String)' cannot be found in class 'javax.swing.filechooser.FileNameExtensionFilter'

 

Has my grey matter gone offline, or my intellect poisoned by expose to too many languages? Or is there a trick, or limitation?

 

                Dave.

 


This email is free from viruses and malware because avast! Antivirus protection is active.





_______________________________________________
Ibm-netrexx mailing list
[hidden email]
Online Archive : http://ibm-netrexx.215625.n3.nabble.com/
 

 




This email is free from viruses and malware because avast! Antivirus protection is active.



_______________________________________________
Ibm-netrexx mailing list
[hidden email]
Online Archive : http://ibm-netrexx.215625.n3.nabble.com/