/** * A collection of two chars, in a non-mutable (non-changeable) way. * This makes it concurrency-safe. */ public class SafeMonogram { private char firstInitial, lastInitial; // the chars themselves public SafeMonogram( char first, char last ) // how to create me { this.firstInitial = first; this.lastInitial = last; } /** * How to get my chars out. * Note, creates a new array each time, so changing the array * doesn't change the SafeMonogram (me). */ public char[] getChars() { char[] chars = new char[2]; chars[0] = this.firstInitial; chars[1] = this.lastInitial; return chars; } }