...I go and discover something new about it. For instance, I never realised you could do this:

class MyClass {
    public static HashMap<String,String> myDict;

    static {
       myDict = new HashMap<String,String>();
       myDict.put( "Do", "A deer, a female deer" );
       myDict.put( "Re", "A drop of golden sun" );
       myDict.put( "Mi", "A name I call myself" );
       myDict.put( "Fa", "A long, long way to run" );
    }

    /* ... more stuff ... */
}

Which is so incredibly useful, I can't believe I never discovered it before.

Edit: and now a not-so-useful example: An alternative 'hello, world':
public class SillyTest {
    static { System.out.println( "Hello, world" ); }
    public static void main( String[] args ) {}
}

Edit 2: That can, in fact, be public static final HashMap<String,String> myDict;, which is arguably more useful.
If you don't have an account you can create one now.
HTML doesn't work in the subject.
More info about formatting

If you are unable to use this captcha for any reason, please contact us by email at support@dreamwidth.org

.

Profile

spudtater: (Default)
spudtater

Most Popular Tags

Powered by Dreamwidth Studios

Style Credit

Expand Cut Tags

No cut tags