• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Arrays.fill( ) - java 2

 
kri shan
Ranch Hand
Posts: 1462
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How shall i pass the int array values from one java class to another java class thru Arrays.fill() (java 2)?
 
marc weber
Sheriff
Posts: 11343
Java Mac Safari
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm sorry, I don't understand your question. Can you be more specific about what you're trying to do?
 
kri shan
Ranch Hand
Posts: 1462
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Marc, Is it possible to pass(transfer) the integer array values from one class to another class thru Arrays.fill() (java 2)?
 
kri shan
Ranch Hand
Posts: 1462
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ie: int[] intArr = new int[10];
int intFillValue = -1;
Arrays.fill(intArr, intFillValue);

How can i pass intArr to another class ?
 
kri shan
Ranch Hand
Posts: 1462
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ie: int[] intArr = new int[10];
int intFillValue = -1;
Arrays.fill(intArr, intFillValue);

How can i pass intArr to another class ?
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Kri,

You don't pass an array to another class using Arrays.fill(). You pass an array as a parameter in a method. Example:



If you want to fill an array with values using Arrays.fill() prior to passing it to another class, that's fine, but the actual passing of the Array to the other class is done through passing of a parameter to a method.
 
kri shan
Ranch Hand
Posts: 1462
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Merril,How shall i pass 1 to 20 as my integer array values from class A to class B ?
 
Henry Wong
author
Marshal
Pie
Posts: 21021
78
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by kri shan:
Hi Merril,How shall i pass 1 to 20 as my integer array values from class A to class B ?


An integer array is just an Object. You may pass it around just like any other object. Options include...

- Having your instance A call a method of instance B with the object.
- Having your instance B call a method of instance A to fetch the object.
- Having your instance A place the object in some reference, which will be fetched by instance B at a later time.
- etc.

Henry
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic