Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
raj vin
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How to pass integer array values from class A to class B ?
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34681
367
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Raj,
The same way you pass any parameter.

A-method() {
int[] array = ...
b.method(array);
}
 
Srikanth Ramu
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 152
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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!!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic