sandip chitale's blog    Sandip Chitale's blog (scblog)
NOTE: I have moved many of my modules to NetBeans Plugin Portal . Please check there for latest versions of modules described on this blog.
20070604 Monday June 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.


Posted by sandipchitale ( Jun 04 2007, 06:16:52 PM PDT ) Permalink Comments [5]


Trackback URL: http://blogs.sun.com/scblog/entry/tip_declaration_and_initialization_of
Comments:

Sad, I must say. Looks like I nice tree on the other side, if you go further away from the screen :)

Posted by Thomas Zillinger on June 06, 2007 at 03:10 AM PDT #

I just filed a bug about not being able to add a property to the Session Bean via the right-click menu. http://www.netbeans.org/issues/show_bug.cgi?id=106148 This functionality was available in 5.5, but I am told this will not be fixed for 6.0. Why are regression bugs not being considered for the 6.0 release? Your name was on a related bug, and I do not know who else to address this with.

Posted by John Parker on June 11, 2007 at 08:38 AM PDT #

John, Thanks for your feedback.

In fact during 6.0 development the infrastructure for Java language was changed from JMI/MDR based to Retouche/Javac based. As a result a lot of regressions appeared and then were addressed. I thought this feature was one such feature and thought it will come back. I was surprised to find out that will not be the case. I will let the developers know. You can send an email on nbdev@netbeans.org.

Sorry this is not very satisfactory.

Posted by Sandip on June 11, 2007 at 09:44 AM PDT #

Java 5 improves it somewhat:

import static java.util.Arrays.asList;
import static java.util.Collections.unmodifiableSet;

...

static final Set<String> stringSet =
___unmodifiableSet(
______new HashSet<String>(
_________asList("foo", "bar", "baz")));

Posted by Rafael de F. Ferreira on October 24, 2007 at 01:33 PM PDT #

varargs of course. I had missed that. Thanks.

Posted by Sandip on October 24, 2007 at 01:56 PM PDT #

Post a Comment:

Name:
E-Mail:
URL:

Your Comment:

HTML Syntax: NOT allowed








« November 2009
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

Get NetBeans 5.5

Locations of visitors to this page

Today's Page Hits: 566


XML
All
/Creator
/General
/Hobby
/Java
/JavaScript
/Mozilla
/NetBeans
/Ubuntu
/VisualWeb
/VisualWebPack
/Web 2.0

XML
All
/Creator
/General
/Hobby
/Java
/JavaScript
/Mozilla
/NetBeans
/Ubuntu
/VisualWeb
/VisualWebPack
/Web 2.0

scblog
scblog