Strings are objects, objects can be added to a list. Let’s examine this in more detail. Assume we have access to the class that’s define below:
In the example below we first create a list meant for storing
Person type object, after which we add persons to it. Finally the person objects are printed one by one.
Adding user-inputted objects to a list
Below is an example of adding users to a list:
Add to the list a new person whose name is the previous user input.
Print the number of the entered persons, and their individual information:
My site is free of ads and trackers. Was this post helpful to you? Why not