This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes Beginning Java and the fly likes pass integer array values from class A's method  to class B's method ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "pass integer array values from class A Watch "pass integer array values from class A New topic
Author

pass integer array values from class A's method to class B's method ?

raj vin
Greenhorn

Joined: Mar 17, 2007
Posts: 12
How to pass integer array values from class A to class B ?
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30356
    
150

Raj,
The same way you pass any parameter.

A-method() {
int[] array = ...
b.method(array);
}


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Srikanth Ramu
Ranch Hand

Joined: Feb 20, 2007
Posts: 76
If Class B extends Class A then you can directly use the variables of Class A provided they are not private variables.
Sidd Kulk
Ranch Hand

Joined: Feb 20, 2007
Posts: 152
I would like to add that an array(Primitive array) is no different from any other object in java, as far as its storage on heap is concerned. The only difference(shared by String objects too) is that its objects can be directly typed in your code.


Sid
Njoy!!
 
wood burning stoves
 
subject: pass integer array values from class A's method to class B's method ?