Assign information to element in array in java [closed]

Yes, instead of having an array of primitive types (like ints) or Strings, define your own class and then create an array of that. Then you can have whatever information you want in there.

Alternatively, if the array must be an array of primitives or Strings because some other method requires it to be in that form, you could either create a second array like that on demand, or use a second array for the associated data (again you might create your own class for this).

Browse More Popular Posts

Leave a Comment