• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Passing Array as an Argument

 
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How to pass the array in a method as an argument and call parameters.
 
Ranch Hand
Posts: 1512
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Noorulain Khan
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 1246
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1512
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
"The Hood"
Posts: 8521
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
I am not a spy. Definitely. Definitely not a spy. Not me. No way. But this tiny ad ...
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic