How would I create an object that uses String type behaviour for creation?

Posted by Zachary Spencer on Stack Overflow See other posts from Stack Overflow or by Zachary Spencer
Published on 2010-04-14T13:54:21Z Indexed on 2010/04/14 14:03 UTC
Read the original article Hit count: 207

I'd like to be able to create an object that is created like a String object, and when created verifies that the String value is an appropriate option.

I.E. SpecificString can be "Bob" or "Jim".

SpecificString BadName = "Sam" //Throws exception SpecificString GoodName = "Bob" //Does not throw exception.

Is this possible?

© Stack Overflow or respective owner

Related posts about java

Related posts about strings