aspose file tools
The moose likes Beginning Java and the fly likes Passing Array as an Argument Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Java » Beginning Java
Reply Bookmark "Passing Array as an Argument" Watch "Passing Array as an Argument" New topic
Author

Passing Array as an Argument

Noorulain Khan
Greenhorn

Joined: Jul 31, 2001
Posts: 28
How to pass the array in a method as an argument and call parameters.
Bosun Bello
Ranch Hand

Joined: Nov 06, 2000
Posts: 1506
Here is a method signature that takes a String array as a parameter and also returns an int array.
int[] myMethodName(String[])
To call this method and use it's return value, declare an int array to hold it's return value and then call it with a variable declared to hold a string array.


------------------
Bosun
SCJP for the Java� 2 Platform


Bosun (SCJP, SCWCD)
So much trouble in the world -- Bob Marley
Noorulain Khan
Greenhorn

Joined: Jul 31, 2001
Posts: 28
Can you please solve this one:
Question Number 4:
>
> Create a TestClass with a main method and create two
> non-static methods m1 and m2 which don't return
> anything. m1 does not take any arguments but m2 takes
> two arguments of a character and one of array.
> Initialize an array with two characters in m1 method.
> Call the m2 method in the m1 method but you have to
> change the two characters initialized in the array m1
> and also the character in the method in m2. In the end
> print the character and the array in the main method
> by creating an object of Test class and calling the
> non-static method m1.
Fei Ng
Ranch Hand

Joined: Aug 26, 2000
Posts: 1241
Homework question??
try to have something... some code
and post it here. Its not learning if we just solve it for you.

happy new year.

[This message has been edited by FEI NG (edited January 01, 2002).]
Bosun Bello
Ranch Hand

Joined: Nov 06, 2000
Posts: 1506
Like Fei said, post some code to at least let us know that you've tried. We will not be doing you any justice by doing it for you. Nobody will do it for you in the real world. Besides, this does not sound too difficult.


------------------
Bosun
SCJP for the Java� 2 Platform
Cindy Glass
"The Hood"
Sheriff

Joined: Sep 29, 2000
Posts: 8521
OK I'll start:

Now you take a stab at outlining the two methods and we will critique it.
Then we will work on the initializing a calling parts afterwards.


"JavaRanch, where the deer and the Certified play" - David O'Meara
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Passing Array as an Argument
 
Similar Threads
Object Referencing
MAIN method
compile eror or runtime error
Recursive method and an array
Class.forName ("java.lang.String[]")