comp.lang.java.programmer
http://groups-beta.google.com/group/comp.lang.java.programmer
[EMAIL PROTECTED]

Today's topics:

* Problem with IE and Applets. - 2 messages, 1 author
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/85712e86df721a37
* store whole InputStream in a String - 21 messages, 5 authors
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/d510835287103e9
* What's the additional value of 'EnumMap' ? - 2 messages, 2 authors
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/731db423dd8a0ec2
* Is this correct? - 1 messages, 1 author
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/a53fa92b22178b7e
* chinese mappings - 1 messages, 1 author
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/276bc9f785792cc5
  
==========================================================================
TOPIC: Problem with IE and Applets.
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/85712e86df721a37
==========================================================================

== 1 of 2 ==
Date:   Sun,   Sep 12 2004 1:37 am
From: Andrew Thompson <[EMAIL PROTECTED]> 

On 12 Sep 2004 00:25:38 -0700, Vardan wrote:

> When i make html file, and include there this code:
> <applet 
...
>    code="myapplet.MainClass"

Try..
code="myapplet.MainClass.class"
...
>    alt="jChatBox Client Applet">

If it is 'myapplet', why did you write the 
alt as 'jChatBox Client Applet'?

> </applet>
...
> But when i open http://www.javazoom.net/services/jchatbox/jchatbox.html
> and run there applet it's work.

What applet?  There are four frames in that page,
and while there is a lot of Javascript in the pages 
I looked at, there was not a single applet/object
call to Java classes to be seen.

-- 
Andrew Thompson
http://www.PhySci.org/ Open-source software suite
http://www.PhySci.org/codes/ Web & IT Help
http://www.1point1C.org/ Science & Technology



== 2 of 2 ==
Date:   Sun,   Sep 12 2004 1:38 am
From: Andrew Thompson <[EMAIL PROTECTED]> 

On 12 Sep 2004 00:25:38 -0700, Vardan wrote:

Can you run this applet?
What results do you get?
<http://www.physci.org/pc/property.jsp?prop=java.version+java.vendor>

-- 
Andrew Thompson
http://www.PhySci.org/ Open-source software suite
http://www.PhySci.org/codes/ Web & IT Help
http://www.1point1C.org/ Science & Technology




==========================================================================
TOPIC: store whole InputStream in a String
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/d510835287103e9
==========================================================================

== 1 of 21 ==
Date:   Sun,   Sep 12 2004 1:59 am
From: "ak" <[EMAIL PROTECTED]> 

Paul,

code you write are may be ok, but comments you write are not ok.
Explain me one thing please - if you writing so reliable code,
why your last arachnofillia after click on "Clear file list below"
clears complete File menu?

-- 
Andrei Kouznetsov
http://uio.dev.java.net Unified I/O for Java
http://reader.imagero.com Java image reader





== 2 of 21 ==
Date:   Sun,   Sep 12 2004 2:16 am
From: Paul Lutus <[EMAIL PROTECTED]> 

ak wrote:

> Paul,
> 
> code you write are may be ok, but comments you write are not ok.
> Explain me one thing please - if you writing so reliable code,
> why your last arachnofillia after click on "Clear file list below"
> clears complete File menu?

Your statement is false. The Arachnophilia command "clear file list below"
does exactly what it says it does, and nothing else.

What happens when you select a menu item in a GUI program? This action
carries out the command and dismisses the menu itself. This is exactly what
happens when this specific command is issued in Arachnophilia. When you
reopen the menu, the file list has been cleared, as intended.

-- 
Paul Lutus
http://www.arachnoid.com




== 3 of 21 ==
Date:   Sun,   Sep 12 2004 2:19 am
From: "ak" <[EMAIL PROTECTED]> 

"Paul Lutus" <[EMAIL PROTECTED]> schrieb im Newsbeitrag
news:[EMAIL PROTECTED]
> ak wrote:
>
> > Paul,
> >
> > code you write are may be ok, but comments you write are not ok.
> > Explain me one thing please - if you writing so reliable code,
> > why your last arachnofillia after click on "Clear file list below"
> > clears complete File menu?
>
> Your statement is false. The Arachnophilia command "clear file list below"
> does exactly what it says it does, and nothing else.
>
> What happens when you select a menu item in a GUI program? This action
> carries out the command and dismisses the menu itself. This is exactly
what
> happens when this specific command is issued in Arachnophilia. When you
> reopen the menu, the file list has been cleared, as intended.

no, it shows empty menu

-- 
Andrei Kouznetsov
http://uio.dev.java.net Unified I/O for Java
http://reader.imagero.com Java image reader





== 4 of 21 ==
Date:   Sun,   Sep 12 2004 2:24 am
From: "Vincent Lascaux" <[EMAIL PROTECTED]> 

> // using while
>
> int len;
> while((len = inputStream.read(buffer)) > 0) {
> bout.write(buffer, 0, len);
> }
>
> // using for
>
> for(int len;(len = inputStream.read(buffer)) > 0;) {
> bout.write(buffer, 0, len);
> }

In fact, those two codes look pretty much the same. This is a good 
demonstration that while and for can be interchanged.
Since you can do that every time (use a for instead of a while, and a while 
instead of a for), we need a "rule" to say when use which. I say that in 
this case, since there is no incrementation part in the for loop, we should 
use the while.
I make one exception to this rule (but hell... if there were no exception, 
it wouldnt be a rule, would it? ;)) for iterators: in java, the 
incrementation is done in the first line of the body part of the loop, but I 
still use for because I'm used to iterating data structures with a for loop

> In any case, the problem with those versions that duplicate one line of 
> code
> is that there is a duplicate line of code, something professional code
> administrators try to avoid at all costs.

I can't agree more with you.

> The problem with "while(true)" should be obvious to all -- it is a hack, 
> as
> is the use of "break" to get around the original hack.

I would not say that... I understand the necessity to have a loop that 
decides to exit in the middle of its body. The condition of your solution 
(which is also mine since I do use the same construction when this problem 
arise) is not a pure condition: it actually does things, and this may also 
be considered as a hack. What if the code we had to launch before the test 
was two lines long?
I don't know what I prefer between writing a small function to handle that 
(that does the code and return whether there is something to be treated) or 
the while(true)/break solution...

-- 
Vincent





== 5 of 21 ==
Date:   Sun,   Sep 12 2004 2:29 am
From: Paul Lutus <[EMAIL PROTECTED]> 

ak wrote:

> "Paul Lutus" <[EMAIL PROTECTED]> schrieb im Newsbeitrag
> news:[EMAIL PROTECTED]
>> ak wrote:
>>
>> > Paul,
>> >
>> > code you write are may be ok, but comments you write are not ok.
>> > Explain me one thing please - if you writing so reliable code,
>> > why your last arachnofillia after click on "Clear file list below"
>> > clears complete File menu?
>>
>> Your statement is false. The Arachnophilia command "clear file list
>> below" does exactly what it says it does, and nothing else.
>>
>> What happens when you select a menu item in a GUI program? This action
>> carries out the command and dismisses the menu itself. This is exactly
> what
>> happens when this specific command is issued in Arachnophilia. When you
>> reopen the menu, the file list has been cleared, as intended.
> 
> no, it shows empty menu

If you download the current version of Arachnophilia and use it with the
current JVM, and unless you have mucked up the menus (possible because
Arachnophilia allows the user to modify the menus), your statement is
false.

-- 
Paul Lutus
http://www.arachnoid.com




== 6 of 21 ==
Date:   Sun,   Sep 12 2004 2:30 am
From: "Vincent Lascaux" <[EMAIL PROTECTED]> 

> code you write are may be ok, but comments you write are not ok.
> Explain me one thing please - if you writing so reliable code,
> why your last arachnofillia after click on "Clear file list below"
> clears complete File menu?

Hey! But what does it have to do with the topic?
Are you so out of arguments on the subject that you have to look for 
mistakes/problems in Paul's code?

-- 
Vincent





== 7 of 21 ==
Date:   Sun,   Sep 12 2004 2:31 am
From: "ak" <[EMAIL PROTECTED]> 

> code you write are may be ok, but comments you write are not ok.
> Explain me one thing please - if you writing so reliable code,
> why your last arachnofillia after click on "Clear file list below"
> clears complete File menu?

File menu behavior it pretty strange:
    File ist is not not below, it is above.
    After open and close some files only file list is present in file menu -
till restart.

-- 
Andrei Kouznetsov
http://uio.dev.java.net Unified I/O for Java
http://reader.imagero.com Java image reader





== 8 of 21 ==
Date:   Sun,   Sep 12 2004 2:36 am
From: "ak" <[EMAIL PROTECTED]> 

> > code you write are may be ok, but comments you write are not ok.
> > Explain me one thing please - if you writing so reliable code,
> > why your last arachnofillia after click on "Clear file list below"
> > clears complete File menu?
>
> Hey! But what does it have to do with the topic?
> Are you so out of arguments on the subject that you have to look for
> mistakes/problems in Paul's code?

We spoke abot reliable code.
He mean my code are wrong and his code ok.
I brought counter-example.

-- 
Andrei Kouznetsov
http://uio.dev.java.net Unified I/O for Java
http://reader.imagero.com Java image reader





== 9 of 21 ==
Date:   Sun,   Sep 12 2004 2:43 am
From: Paul Lutus <[EMAIL PROTECTED]> 

Vincent Lascaux wrote:

>> // using while
>>
>> int len;
>> while((len = inputStream.read(buffer)) > 0) {
>> bout.write(buffer, 0, len);
>> }
>>
>> // using for
>>
>> for(int len;(len = inputStream.read(buffer)) > 0;) {
>> bout.write(buffer, 0, len);
>> }
> 
> In fact, those two codes look pretty much the same. This is a good
> demonstration that while and for can be interchanged.
> Since you can do that every time (use a for instead of a while, and a
> while instead of a for),

But you can't do it every time. A for-loop has three clauses that are
carried out in a specific way. You can dispense with the three clauses,
making "for" resemble "while," but the reverse isn't true.

> we need a "rule" to say when use which. I say 
> that in this case, since there is no incrementation part in the for loop,
> we should use the while.

Seems reasonable, unless a case arises in which the control variable needs
to be kept local. In that case, it is the *effect* of using a for-loop, not
its appearance, that is more important.

Also, there are plenty of cases where a while-loop also involves
incrementation. I think the more basic difference is the for-loop's three
clauses, and times where this is the obvious choice.

> I make one exception to this rule (but hell... if there were no exception,
> it wouldnt be a rule, would it? ;)) for iterators: in java, the
> incrementation is done in the first line of the body part of the loop, but
> I still use for because I'm used to iterating data structures with a for
> loop
> 
>> In any case, the problem with those versions that duplicate one line of
>> code
>> is that there is a duplicate line of code, something professional code
>> administrators try to avoid at all costs.
> 
> I can't agree more with you.
> 
>> The problem with "while(true)" should be obvious to all -- it is a hack,
>> as
>> is the use of "break" to get around the original hack.
> 
> I would not say that... I understand the necessity to have a loop that
> decides to exit in the middle of its body.

It is best avoided, replaced by something that exits in a way easy to
visualize, otherwise the programmer may picture the algorithm in a way at
odds with reality.

> The condition of your solution 
> (which is also mine since I do use the same construction when this problem
> arise) is not a pure condition: it actually does things, and this may also
> be considered as a hack.

Only if it can be replaced with something better. But it can't. In any case,
there is no reason to avoid actions along with tests if that is the most
efficient arrangement.

> What if the code we had to launch before the test 
> was two lines long?

In that case I would call a method in order to maintain the structure of the
while loop.

> I don't know what I prefer between writing a small function to handle that
> (that does the code and return whether there is something to be treated)
> or the while(true)/break solution...

The former meets the requirement to break actions up into logical units. The
latter IMHO is an acknowledgment of defeat. :)


-- 
Paul Lutus
http://www.arachnoid.com




== 10 of 21 ==
Date:   Sun,   Sep 12 2004 2:46 am
From: "ak" <[EMAIL PROTECTED]> 

> >> > code you write are may be ok, but comments you write are not ok.
> >> > Explain me one thing please - if you writing so reliable code,
> >> > why your last arachnofillia after click on "Clear file list below"
> >> > clears complete File menu?
> >>
> >> Your statement is false. The Arachnophilia command "clear file list
> >> below" does exactly what it says it does, and nothing else.
> >>
> >> What happens when you select a menu item in a GUI program? This action
> >> carries out the command and dismisses the menu itself. This is exactly
> > what
> >> happens when this specific command is issued in Arachnophilia. When you
> >> reopen the menu, the file list has been cleared, as intended.
> >
> > no, it shows empty menu
>
> If you download the current version of Arachnophilia and use it with the
> current JVM, and unless you have mucked up the menus (possible because
> Arachnophilia allows the user to modify the menus), your statement is
> false.

if you would read what I wrote, you could see that I wrote "your last
Arachnofillia".
"last" means I just downloaded it.
And yes I use java 1.4

> and unless you have mucked up the menus (possible because
> Arachnophilia allows the user to modify the menus).

yup, I modified the menu some time ago.
Sorry - I tried to modify menu.
That was a bit a disaster (another bugs in your code?)

And sorry, but I didn't found the way to reset menu.

-- 
Andrei Kouznetsov
http://uio.dev.java.net Unified I/O for Java
http://reader.imagero.com Java image reader





== 11 of 21 ==
Date:   Sun,   Sep 12 2004 2:47 am
From: Paul Lutus <[EMAIL PROTECTED]> 

ak wrote:

>> code you write are may be ok, but comments you write are not ok.
>> Explain me one thing please - if you writing so reliable code,
>> why your last arachnofillia after click on "Clear file list below"
>> clears complete File menu?
> 
> File menu behavior it pretty strange:
>     File ist is not not below, it is above.

As I expected, you have mucked up your menus. Re-install Arachnophilia, and
use the customization features more carefully.

-- 
Paul Lutus
http://www.arachnoid.com




== 12 of 21 ==
Date:   Sun,   Sep 12 2004 2:49 am
From: Paul Lutus <[EMAIL PROTECTED]> 

ak wrote:

>> > code you write are may be ok, but comments you write are not ok.
>> > Explain me one thing please - if you writing so reliable code,
>> > why your last arachnofillia after click on "Clear file list below"
>> > clears complete File menu?
>>
>> Hey! But what does it have to do with the topic?
>> Are you so out of arguments on the subject that you have to look for
>> mistakes/problems in Paul's code?
> 
> We spoke abot reliable code.
> He mean my code are wrong and his code ok.
> I brought counter-example.

It is not a counterexample. You have managed to screw up your Arachnophilia
menus. To see how severely, re-install Arachnophilia using the provided
instructions to assure that your menus are recreated.

If you do this, suddenly everything will work correctly, until you play with
the menu structure again.

-- 
Paul Lutus
http://www.arachnoid.com




== 13 of 21 ==
Date:   Sun,   Sep 12 2004 3:01 am
From: Tor Iver Wilhelmsen <[EMAIL PROTECTED]> 

"Vincent Lascaux" <[EMAIL PROTECTED]> writes:

> for(Iterator i = start; i.hasNext(); i.next()) {
>  something q = i.current();
> }
> 
> The C# and C++ STL iterators work like that (well, same idea), and I am more 
> used to reading a for statement with an "inc" as a third "parameter"

Java also has an iterator that works like that: java.sql.ResultSet.

But then java.sql.* generally breaks with a few "Javaisms" (like
indexes starting with 1 instead of 0) anyway.

In JRE 5.0 (1.5.0) you can do

for (Sometype i: someList) {
//...
}

whether someList is a (typed) List or an array. Makes life simpler.



== 14 of 21 ==
Date:   Sun,   Sep 12 2004 2:58 am
From: "ak" <[EMAIL PROTECTED]> 

"Paul Lutus" <[EMAIL PROTECTED]> schrieb im Newsbeitrag
news:[EMAIL PROTECTED]
> ak wrote:
>
> >> code you write are may be ok, but comments you write are not ok.
> >> Explain me one thing please - if you writing so reliable code,
> >> why your last arachnofillia after click on "Clear file list below"
> >> clears complete File menu?
> >
> > File menu behavior it pretty strange:
> >     File ist is not not below, it is above.
>
> As I expected, you have mucked up your menus. Re-install Arachnophilia,
and
> use the customization features more carefully.

I found the error, file list was at top position in menu.
Indeed it is error in code.
User may want to have file list anywhere...
Why should clearing file list also clear complete File menu just because
file list is in wrong place?

-- 
Andrei Kouznetsov
http://uio.dev.java.net Unified I/O for Java
http://reader.imagero.com Java image reader





== 15 of 21 ==
Date:   Sun,   Sep 12 2004 3:00 am
From: "ak" <[EMAIL PROTECTED]> 

> >> code you write are may be ok, but comments you write are not ok.
> >> Explain me one thing please - if you writing so reliable code,
> >> why your last arachnofillia after click on "Clear file list below"
> >> clears complete File menu?
> >
> > File menu behavior it pretty strange:
> >     File ist is not not below, it is above.
>
> As I expected, you have mucked up your menus. Re-install Arachnophilia,
and
> use the customization features more carefully.

consider to provide "Reset menus" button

-- 
Andrei Kouznetsov
http://uio.dev.java.net Unified I/O for Java
http://reader.imagero.com Java image reader





== 16 of 21 ==
Date:   Sun,   Sep 12 2004 3:00 am
From: Paul Lutus <[EMAIL PROTECTED]> 

ak wrote:

>> >> > code you write are may be ok, but comments you write are not ok.
>> >> > Explain me one thing please - if you writing so reliable code,
>> >> > why your last arachnofillia after click on "Clear file list below"
>> >> > clears complete File menu?
>> >>
>> >> Your statement is false. The Arachnophilia command "clear file list
>> >> below" does exactly what it says it does, and nothing else.
>> >>
>> >> What happens when you select a menu item in a GUI program? This action
>> >> carries out the command and dismisses the menu itself. This is exactly
>> > what
>> >> happens when this specific command is issued in Arachnophilia. When
>> >> you reopen the menu, the file list has been cleared, as intended.
>> >
>> > no, it shows empty menu
>>
>> If you download the current version of Arachnophilia and use it with the
>> current JVM, and unless you have mucked up the menus (possible because
>> Arachnophilia allows the user to modify the menus), your statement is
>> false.
> 
> if you would read what I wrote, you could see that I wrote "your last
> Arachnofillia".
> "last" means I just downloaded it.

No, "last" does not mean "I just downloaded it."

> And yes I use java 1.4

That is not the most recent version. We have a perfect score of zero.

>> and unless you have mucked up the menus (possible because
>> Arachnophilia allows the user to modify the menus).
> 
> yup, I modified the menu some time ago.
> Sorry - I tried to modify menu.
> That was a bit a disaster (another bugs in your code?)

If you write a bad novel, do you then blame the typewriter manufacturer?

You are the sort of person for whom advanced features are a constant danger.
 
> And sorry, but I didn't found the way to reset menu.

Try reading the instructions.

http://www.arachnoid.com/arachnophilia/Documentation/arachnofaq.html#link1

-- 
Paul Lutus
http://www.arachnoid.com




== 17 of 21 ==
Date:   Sun,   Sep 12 2004 3:02 am
From: "Vincent Lascaux" <[EMAIL PROTECTED]> 

> But you can't do it every time. A for-loop has three clauses that are
> carried out in a specific way. You can dispense with the three clauses,
> making "for" resemble "while," but the reverse isn't true.

for(Init; Cond; Inc) { Body; } <=> { Init; while(Cond) { Body; Inc; } }
while(Cond) { Body; } <=> for(;Cond;) { Body; }

> Seems reasonable, unless a case arises in which the control variable needs
> to be kept local. In that case, it is the *effect* of using a for-loop, 
> not
> its appearance, that is more important.

I agree. But this case is (or at least should be) rare: if you use several 
loops in one function, chances are that you should split it in several 
functions.

-- 
Vincent 





== 18 of 21 ==
Date:   Sun,   Sep 12 2004 3:02 am
From: Paul Lutus <[EMAIL PROTECTED]> 

ak wrote:

>> >> code you write are may be ok, but comments you write are not ok.
>> >> Explain me one thing please - if you writing so reliable code,
>> >> why your last arachnofillia after click on "Clear file list below"
>> >> clears complete File menu?
>> >
>> > File menu behavior it pretty strange:
>> >     File ist is not not below, it is above.
>>
>> As I expected, you have mucked up your menus. Re-install Arachnophilia,
> and
>> use the customization features more carefully.
> 
> consider to provide "Reset menus" button

Already true! How long is this going to take, exactly? Please read the
documentation.

-- 
Paul Lutus
http://www.arachnoid.com




== 19 of 21 ==
Date:   Sun,   Sep 12 2004 3:05 am
From: Paul Lutus <[EMAIL PROTECTED]> 

ak wrote:

> "Paul Lutus" <[EMAIL PROTECTED]> schrieb im Newsbeitrag
> news:[EMAIL PROTECTED]
>> ak wrote:
>>
>> >> code you write are may be ok, but comments you write are not ok.
>> >> Explain me one thing please - if you writing so reliable code,
>> >> why your last arachnofillia after click on "Clear file list below"
>> >> clears complete File menu?
>> >
>> > File menu behavior it pretty strange:
>> >     File ist is not not below, it is above.
>>
>> As I expected, you have mucked up your menus. Re-install Arachnophilia,
> and
>> use the customization features more carefully.
> 
> I found the error, file list was at top position in menu.
> Indeed it is error in code.

No, it was error in user. You moved it into that position.

> User may want to have file list anywhere...

User needs reboot.

> Why should clearing file list also clear complete File menu just because
> file list is in wrong place?

I am now considering a version of Arachnophilia without the advanced
features, specifically for rocket-scientist users like this one.

-- 
Paul Lutus
http://www.arachnoid.com




== 20 of 21 ==
Date:   Sun,   Sep 12 2004 3:47 am
From: "ak" <[EMAIL PROTECTED]> 

"Vincent Lascaux" <[EMAIL PROTECTED]> schrieb im Newsbeitrag
news:[EMAIL PROTECTED]
> > code you write are may be ok, but comments you write are not ok.
> > Explain me one thing please - if you writing so reliable code,
> > why your last arachnofillia after click on "Clear file list below"
> > clears complete File menu?
>
> Hey! But what does it have to do with the topic?
> Are you so out of arguments on the subject that you have to look for
> mistakes/problems in Paul's code?

you are right of course, I was a little bit childish ;-)

-- 
Andrei Kouznetsov
http://uio.dev.java.net Unified I/O for Java
http://reader.imagero.com Java image reader





== 21 of 21 ==
Date:   Sun,   Sep 12 2004 3:56 am
From: Timo Kinnunen <[EMAIL PROTECTED]> 

On Sun, 12 Sep 2004 11:02:17 +0100, Vincent Lascaux wrote:

>> But you can't do it every time. A for-loop has three clauses that are
>> carried out in a specific way. You can dispense with the three clauses,
>> making "for" resemble "while," but the reverse isn't true.
> 
> for(Init; Cond; Inc) { Body; } <=> { Init; while(Cond) { Body; Inc; } }

Calling { Init; while(Cond) { Body; Inc; } } a while-construct and not a
block-construct with a while has a few problems. First, when reading the
first brace it's not possible to determine that what you're reading is this
construct without looking ahead. Second, I find it unnatural to initialize
multiple variables in a single statement except in a for-loop, so I'd
rather write them out, which, while semantically identical, can't be
converted to a corresponding for-construct.

I guess I could train myself to consider this one

{ int i = 0, n = array.length; while(i < n) {
  //process
  i++;
}}

on par with

for(int i = 0, n = array.length; i < n; i++) {
  //process
}

but I just find it ugly.




==========================================================================
TOPIC: What's the additional value of 'EnumMap' ?
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/731db423dd8a0ec2
==========================================================================

== 1 of 2 ==
Date:   Sun,   Sep 12 2004 2:32 am
From: [EMAIL PROTECTED] 

What's the additional value of 'EnumMap' ?

I'm asking this, because it seems to me that the same 
result can be accomplished by using a plain 'HashMap' (?). 
See these two examples :

******

Example 01 (with 'EnumMap') :

   public enum TrafficLightColor { red, orange, green };

   public void getInstruction()
   {
      EnumMap<TrafficLightColor, String> instructions = 
           new EnumMap<TrafficLightColor, String>(TrafficLightColor.class);
      instructions.put(TrafficLightColor.red, "Stop");
      instructions.put(TrafficLightColor.orange, "Slow down or accelerate");
      instructions.put(TrafficLightColor.green, "Drive");

      TrafficLightColor k = TrafficLightColor.red;
      System.out.printf("The instruction for color %s is : '%s'.", k, 
instructions.get(k));
   }

******

Example 02 (with 'HashMap') :

   public enum TrafficLightColor { red, orange, green };

   public void getInstruction()
   {
      HashMap<TrafficLightColor, String> instructions = 
         new HashMap<TrafficLightColor, String>();
      instructions.put(TrafficLightColor.red, "Stop");
      instructions.put(TrafficLightColor.orange, "Slow down or accelerate");
      instructions.put(TrafficLightColor.green, "Drive");

      TrafficLightColor k = TrafficLightColor.red;
      System.out.printf("The instruction for color %s is : '%s'.", k, 
instructions.get(k));
   }

******

The outcome is the same, so what's the big difference ? 
Why (or when) would one prefer to use 'EnumMap'
in favor to 'HashMap' ?



== 2 of 2 ==
Date:   Sun,   Sep 12 2004 3:22 am
From: Lasse Reichstein Nielsen <[EMAIL PROTECTED]> 

[EMAIL PROTECTED] writes:

> Why (or when) would one prefer to use 'EnumMap'
> in favor to 'HashMap' ?

Efficiency. EnumMap is a specialized implementation of Map, where
HashMap is very general. Specializing allows using non-general
optimizations. An EnumMap is optimized to hold only enumeration
values, and it doesn't need to, e.g., call hashcode() on the
values. 

As enum values can be mapped to small integers, an EnumMap might be
implemented using an array. (Hmm, that's easy to check, the source
code for EnumMap is available. And yes, it uses an array :).

/L
-- 
Lasse Reichstein Nielsen  -  [EMAIL PROTECTED]
 DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
  'Faith without judgement merely degrades the spirit divine.'




==========================================================================
TOPIC: Is this correct?
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/a53fa92b22178b7e
==========================================================================

== 1 of 1 ==
Date:   Sun,   Sep 12 2004 3:25 am
From: "Tony Morris" <[EMAIL PROTECTED]> 

package spelling.correct;

class Colour extends Color
{
    // All those constructors
}

// :)

-- 
Tony Morris
http://xdweb.net/~dibblego/






==========================================================================
TOPIC: chinese mappings
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/276bc9f785792cc5
==========================================================================

== 1 of 1 ==
Date:   Sun,   Sep 12 2004 3:22 am
From: steve <[EMAIL PROTECTED]> 

Hi,

I am looking for chinese "mapping" files. ( possibly pinyin etc)
As i am currently writing a number of  asian language input methods

these are files that map  a group of chinese characters to a text string.

the file contains a string such as :

Ai  {tab} unicode-mapping unicode-mapping  unicode-mapping  
bing  {tab} unicode-mapping unicode-mapping  unicode-mapping 
wong  {tab} unicode-mapping unicode-mapping  unicode-mapping 

any help will be greatly received.

steve
 




=======================================================================

You received this message because you are subscribed to the
Google Groups "comp.lang.java.programmer".  

comp.lang.java.programmer
[EMAIL PROTECTED]

Change your subscription type & other preferences:
* click http://groups-beta.google.com/group/comp.lang.java.programmer/subscribe

Report abuse:
* send email explaining the problem to [EMAIL PROTECTED]

Unsubscribe:
* click http://groups-beta.google.com/group/comp.lang.java.programmer/subscribe


=======================================================================
Google Groups: http://groups-beta.google.com 



------------------------ Yahoo! Groups Sponsor --------------------~--> 
Make a clean sweep of pop-up ads. Yahoo! Companion Toolbar.
Now with Pop-Up Blocker. Get it for free!
http://us.click.yahoo.com/L5YrjA/eSIIAA/yQLSAA/BCfwlB/TM
--------------------------------------------------------------------~-> 

<a href=http://English-12948197573.SpamPoison.com>Fight Spam! Click Here!</a> 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/kumpulan/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 

Reply via email to