KBD

Keith Devens .com

Saturday, October 11, 2008 Flag waving
When your enemy is making a very serious mistake, don't be impolite and disturb him. – Napoleon Bonaparte (allegedly)

Archive: July 24, 2005

← July 22, 2005July 25, 2005 →

Daily link icon Sunday, July 24, 2005

Java's (typed/generic) collections suck (update: no they don't)

Java's typed/generic collections suck are ok, see below:

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class TokenTest {
    public static void main(String[] args) {
        Map<String, List<String[]>> tokenMap = new HashMap<String, List<String[]>>();
        List tokenList = tokenMap.get("foo");
        for (String[] tokenTerms : tokenList){
            System.out.println(tokenTerms);
        }
    }
}

Then:

$>javac TokenTest.java
TokenTest.java:10: incompatible types
found   : java.lang.Object
required: java.lang.String[]
        for (String[] tokenTerms : tokenList){
                                   ^
1 error

Am I doing something wrong or is Java's typing stupid? Also note that Java didn't understand that ArrayList is a subtype of List when I tried to create a new HashMap<String, ArrayList<String[]>>();.

Update: Jürgen pointed out in a comment that List tokenList should have been List<String[]> tokenList. Problem solved. Thanks!

  1. tagfs, via Chris. To read.

       (0) Tags: [Programming]

Atom 1.0 (just about)

ongoing · Atom 1.0. Still not an official release, but pretty close. I'll probably get to it only when it has an RFC number.

Here's the current spec, and here's a comparison between RSS 2.0 and Atom. See atomenabled.org (and atompub.org) for more.

  1. Bill de hÓra: Jython 2.2a1, via Tim. Woot.

       (0) Tags: [Programming]
  2. Buridan's Ass (via). "Two roads diverged in a wood, and I just sat there...". Also see Hobson's choice.

       (0)
  3. Virtual Street Reality (via). Very cool.

       (0) Tags: [Random]
← July 22, 2005July 25, 2005 →
October 2008
SunMonTueWedThuFriSat
 1234
567891011
12131415161718
19202122232425
262728293031 



RSS feed RSS feed for Keith's Weblog
Atom feed Atom feed for Keith's Weblog
Weblog archive
Recent comments
  on 7 posts

Recent comments XML

new⇒I hate PHP

Elliot Anderson,

Dude!! You the​man! The reverse replacement for​array_u...

Alex Ndungu: Oct 11, 1:35am

Call a function from a string in Python

?!code:
some_object.__getattribute​__('method_name')()
?!/code

is​the s...

Patrick Corcoran: Oct 8, 3:53pm

Spider solitaire

I have won 185 games of Spider​Solitaire at the "Difficult" level.​ What is...

75.179.28.113: Oct 8, 12:42pm

Sed one-liners

Hi.

I wanted to let you know​that I wrote an article "Famous Sed​One-Lin...

Peteris Krumins: Oct 8, 3:05am

Timesheet Calculator

Hadn't seen it before now, but my​company already uses a time​tracking prog...

Keith: Oct 7, 10:44am

Girls, please don't get breast implants

Hey everyone, 

I am new to this​blog and I have enjoyed reading all​your...

Sarah.M.: Oct 6, 9:45am

Generated in about 0.063s.

(Used 7 db queries)

mobile phone