multiple values | SoloLearn: Learn to code for FREE!


multiple values

I want to have a 3 attributes for a certain group of items. for example: name - bob country- US job- developer what can i use to store all 3 in one place? arrays can only store 1 (the specific index), and hashmap can only store 2 (value and key). i want to be able to access a value at any point. if i call the country, i want to return US (so 6 labels in total). i was thinking have a hundred arrays would be very inefficent, so what could i do?

5/25/2019 12:21:19 AM

koala 🐨

3 Answers

New Answer


public class Person { String name; String country; String job; ... } In main(): Person p1=new Person; Person p2=new Person; ...


koala Use an array: Person[] p=new[] Person; (the syntax might be wrong, lol)


Jay Matthews thank you, I thought having too many classes would be inefficient but it's fine for what I have to do