0

How to set a primitive data type to only collect a set of values

So in java the boolean primitive data type only accepts true or false. And I want to add a gender attribute to a class. Now I want this attribute to only take male, female or other. And I suppose it's a string I will make use of so is there any way that the String will be set to only accept these values.

14th Aug 2019, 2:53 PM
Ibrahim Adeosun
Ibrahim Adeosun - avatar
2 odpowiedzi
14th Aug 2019, 3:02 PM
Michael
Michael - avatar