File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
A friendly place for programming greenhorns!
Big Moose Saloon
Search
|
Java FAQ
|
Recent Topics
Register / Login
JavaRanch
»
Java Forums
»
Java
»
Beginning Java
Author
Question about a method
Fumie Suguri
Greenhorn
Joined: Nov 21, 2005
Posts: 1
posted
Nov 22, 2005 00:03:00
0
How would you call a method that has an array for its parameter?
vivien siu
Ranch Hand
Joined: Nov 10, 2005
Posts: 143
posted
Nov 22, 2005 00:49:00
0
This is a method with an array of datatype
String
for parameter/argument:
public void method(String[] array)
To call it you just have to pass a String array in the parameter values. Like this:
String[] array = new String[1]; method(array);
I'm not available, my BF's name is WORK.
Jeff Albertson
Ranch Hand
Joined: Sep 16, 2005
Posts: 1780
posted
Nov 22, 2005 06:26:00
0
public class Test { public static void main(String[] args) { //pass it a variable name of array type: int[] a = new int[10]; f(a); //pass it an array created in the call f(new int[10]); //pass it an array created and initialized in the call f(new int[]{3,1,4,1,5,9}); //pass it any expression of array type, like the result of another method call f(another()); } static void f(int[] array) {} static int[] another () { return new int[]{3,1,4,1,5,9}; } }
There is no emoticon for what I am feeling!
I agree. Here's the link:
http://aspose.com/file-tools
subject: Question about a method
Similar Threads
garbage collection
Sharpen your Pencil - Page 323 in HFEJB
Problem with Dynamic File element
Finalization Method
NX: When should I throw DuplicateKeyException?
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter