Im using the following code
List<String> text = new ArrayList<String>();
text.add("Hello");
So that list will only accept Strings to be added, how can I add into one list more types of variables like ints and strings together like
Adding into the text list some rectangle values like
rectangle name, rectangle width, rectangle height
So later I can access them in a loop
Create your own Rectangle
class and store those values in it.
List<Rectangle> rectangles = new ArrayList<>();
rectangles.add(new Rectangle("Foo", 20, 30));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With