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.
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.