aspose file tools
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
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Reply 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: 26144
    
  66

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!!
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: pass integer array values from class A's method to class B's method ?
 
Similar Threads
var-args
Reflection
Iterating through unknown enum type variable
Arrays.fill( ) - java 2
how to pass values of array to jsp page.