spudtater: (Default)
([personal profile] spudtater Oct. 13th, 2006 05:05 pm)
I have finally joined the 21st century and downloaded the Eclipse SDK for Java development. Oooh, luxury. I don't know why I stuck with xemacs for so long!



Also: after worrying about Java generics since Java 5.0 came out, I finally bit the bullet and set to teaching myself how to use them. Result: I had it figured out within about five minutes. Easy!

Non-generic java:
ArrayList a = new ArrayList();
a.add( "the" );
a.add( "quick" );
a.add( "brown" );
a.add( "fox" );
Iterator i = a.iterator();
while( i.hasNext() )
    System.out.println( "Length of string is " + ((String) i.next()).length() );
Which is, for one thing, ugly. (LISPs!) More significantly, it can lead to type conversion errors at runtime, when you'd much prefer to see them at compile time.

Generic java:
ArrayList<String> a = new ArrayList<String>();
a.add( "the" );
a.add( "quick" );
a.add( "brown" );
a.add( "fox" );
Iterator<String> i = a.iterator();
while( i.hasNext() )
    System.out.println( "Length of string is " + i.next().length() );
Which is easy enough to understand — just read ArrayList<String> as "an ArrayList of type String". Iterator<String> means "an Iterator over type String", and so forth.



On another note: have been exposed to the dreaded C#, which Microsoft likes to describes as an updated version of C/C++, with a few influences from Visual Basic and Java. Let's take a look at a HelloWorld program in C#:
public class HelloWorld {
    public static void Main( string[] args ) {
        System.Console.WriteLine( "Hello, world" );
    }
}
Hmmm... not fooling anyone there, Billy. It's Java through-and-through, with a few syntactic differences (for example, upper-case method names) just to piss off existing Java programmers. Teh annoy.

Enough about me. How are you?
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