Top.Mail.Ru
June 15th, 2006 - Java developers — LiveJournal
? ?

Java developers

June 15th, 2006
 

12:36 am - tmagr - HashMap question

I am reading a Java book now which has the following HashMap declaration:
HashMap<String, Integer> scores = new HashMap<String, Integer> ();

The book says that this means the keys are strings and values are integers. Fair enough. So, I'm curious about two things:
1) In real-life, wouldn't it be more common to have the Integer be a key instead of a String? I know this isn't a Java-specific question, but developers here have so much more real-life development experience than me, maybe you can share.

2) Also, I'm wondering, is there ever a situation that would arise where the two types wouldn't match, like, would you ever have something in practice like:
HashMap<Object,Object> scores = new HashMap<String, Integer> ();

Just curious.
 

01:12 am - tmagr - HashMap question (sorry, another one)

One thing which I'm wondering about and can't seem to find on the Java API docs is whether it is possible to get HashMap to use separate chaining instead of over-writing previous values. By "separate chaining," I am talking about a technique I learned in a C++ class in which each key could hold more than one value (because it's possible that more than one entry could hash to the same value. HashMap doesn't seem designed for collisions, no?

12:31 pm - ska_o - passing more than 9 arguments via cmd script

Hi,

This is not a Java question, strictly speaking, but at least it's Java-related.

I know that properties etc. can be used, but I'm interested in the command line in this case.

In a Windows cmd script, one can write

java %1 %2 %3 %4 %5 %6 %7 %8 %9

This will pass arguments 1 through 9 that were supplied on the command line when executing the script.

Is there a way to pass the 10th argument?

Thanks in advance.
 

07:32 pm - curious_tiger - Why doesn't this work?

String [] flintstones = {"Fred","Wilma","Pebbles"};
System.out.println(flintstones); // prints only []; expected is [Fred, Wilma, Pebbles]

I know that I can use a loop to print each of these items individual, but I don't understand why the JVM doesn't know the meaning of something as simple as System.out.println(someArray).

So, basically what I'm asking is a question about language design: why was it done this way?
Powered by LiveJournal.com