I’m doing a project in Java in which I’m looking at the frequency characters occur after each other character in a text. When I’m collecting my results, I’m storing them in a 2d array of ints. However, in the same results table, I want to store some results about the whole thing.
Is it possible to have an array where some of the elements are arrays, and others are primitives?
Yes, you can have
Object[]and store a mix a types, although it would have to be the wrapperInteger(not the primitiveint). (Note: you could “cheat” and save eachintas a single-element arrayint[], thus making it an Object, but “don’t try this at home”)But even if you could, an array isn’t the right approach. Instead, create a class for this.
Try something like this: