Monday Jun 04, 2007

TIP: Declaration and initialization of an unmodifiable static final Set

    static final Set<String> stringSet =
            Collections.unmodifiableSet(
                new HashSet<String>(Arrays.asList(
                    "foo",
                    "bar",
                    "baz"
                    )));

Modified based on a tip by Rafael de F. Ferreira. I cannot use a trailing comma on each line though for easy addition/removal of entries.

About

sandipchitale

Search

Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today