switch using strings

  • Thread starter Dirk Bruere at NeoPax
  • Start date
L

Lew

What so-called "diamond operator"?


Since when is autoboxing "dangerous"?

class Foo
{
public Boolean bill;
public int jill = bill;
}

It also interacts interestingly with varargs.

Of course, GIYF if yoiu really want to know.

Have a bone to pick?

If you consider it bad to know the JLS then you'll never be anything
but a poor Java programmer.

That it's obfuscatory to the untrained intellect is no more of an
issue than that any other technical language is obfuscatory to the
ignorant. That's why it requires experts at large salaries. It's the
subject matter that's tricky.

There will always be the /Harrison Bergeron/ types who believe that
excellence should be easy and who are too lazy to do the work required
to gain true expertise. Such individuals tend to speak disparagingly
of the advocates for hard work and perfection in order to hide their
own well-deserved sense of inferiority.
 
P

Paul Cager

  class Foo
  {
    public Boolean bill;
    public int jill = bill;
  }

My favourite: what is printed by the following class?

import java.util.ArrayList;
import java.util.List;

public class Test1 {
public static void main(String[] args) {
List<Integer> list = new ArrayList<Integer>();

// What is printed?

list.add(Integer.valueOf(42));
list.remove(Integer.valueOf(42));
System.out.println(list.size());

list.add(42);
list.remove(42);
System.out.println(list.size());
}
}
 
J

javax.swing.JSnarker

class Foo
{
public Boolean bill;
public int jill = bill;
}

This should give a type error since neither boolean nor Boolean is
assignable to either int or Integer. Are you implying that it doesn't?
Why not come right out and say exactly what it does?
It also interacts interestingly with varargs.

Varargs just bundles the additional arguments into an array of a
specified type, doesn't it? What is the "interesting interaction".
Of course, GIYF if yoiu really want to know.

It's not clear to me what google query would cause google to index the
inside of your head and tell me exactly what, specifically, you are
thinking of when you declare autoboxing to be "dangerous".
Have a bone to pick?

No, just making an observation.
If you consider it bad to know the JLS then you'll never be anything
but a poor Java programmer.

I don't consider it bad to know the JLS. I'm just snarking on the fact
that you put yourself forth in this newsgroup (and have done for years)
as a very strong advocate for looking everything up in the JLS (a
position I don't necessarily even disagree with) but did, eventually,
admit that the document isn't always the world's most readable.
That it's obfuscatory to the untrained intellect is no more of an
issue than that any other technical language is obfuscatory to the
ignorant. That's why it requires experts at large salaries. It's the
subject matter that's tricky.

Who are you insinuating is "ignorant" and otherwise a deficient
intellect, Lew?
There will always be the /Harrison Bergeron/ types who believe that
excellence should be easy and who are too lazy to do the work required
to gain true expertise.

To coin a phrase: Who is "Harrison Bergeron", Lew? There is nobody in
this newsgroup using that alias. ;)
Such individuals tend to speak disparagingly of the advocates for
hard work and perfection in order to hide their own well-deserved
sense of inferiority.

And some people just occasionally feel the need to puncture the balloon
of someone who constantly puts himself forth as superior to everybody
else, Lew, whether by pointing out a flaw in the person or in something
they have more or less identified themselves with.

--
 
J

javax.swing.JSnarker

The obvious search would be "autoboxing dangerous". Somehow I suspect
you might be too, ah, _lazy_ to try, though.

Perhaps I'm not making myself clear?

I was asking Lew why he holds a particular *personal opinion* on a
matter. That is not a question a google search can be expected to answer.

--
 
M

Martin Gregorie

"autoboxing dangerous"

Brilliant! Just for fun, I tried that query with Scroogle[1] and its a
googlewackblatt[2]. The first I've seen!

[1] Scroogle is a query anonymiser that prevents Google from compiling
your search history. For good measure it also gets rid of most of the
useless paid-for search results that gazump the top of the list.

[2] A googlewackblatt, as any fule kno, is a Google query that returns
exactly one result. I first saw the term in New Scientist's back pages.
 
P

Paul Cager

Perhaps I'm not making myself clear?

I was asking Lew why he holds a particular *personal opinion* on a
matter. That is not a question a google search can be expected to answer.

Spooky. If you type in:
+lew autoboxing dangerous
to Google search you get:
http://www.javakb.com/Uwe/Forum.aspx/java-programmer/36707/Java-7-features
as the first suggestion (or at least I did). And that is a flame-
filled thread talking about "Strings in switch statements" (amongst
other things).

Some would say that's just a coincidence. Personally I think it is a
sure sign that there are Dark and Mysterious Forces at work here.
Pray, fellow programmers, for ye might yet be saved!
 
J

javax.swing.JSnarker

I was asking Lew why he holds a particular *personal opinion* on a
matter. That is not a question a google search can be expected to answer.

Spooky. If you type in:
+lew autoboxing dangerous
to Google search you get:
http://www.javakb.com/Uwe/Forum.aspx/java-programmer/[snip]
Some would say that's just a coincidence. Personally I think it is a
sure sign that there are Dark and Mysterious Forces at work here.

Nah, it's just that some web sites are archiving/mirroring this
newsgroup, and in particular this thread.

--
 
D

Daniele Futtorovic

"autoboxing dangerous"

Brilliant! Just for fun, I tried that query with Scroogle[1] and its a
googlewackblatt[2]. The first I've seen!

[1] Scroogle is a query anonymiser that prevents Google from compiling
your search history. For good measure it also gets rid of most of the
useless paid-for search results that gazump the top of the list.

[2] A googlewackblatt, as any fule kno, is a Google query that returns
exactly one result. I first saw the term in New Scientist's back pages.

Discovered this one recently: http://duckduckgo.com/. I like it.

It does indeed serve the spooky result first, but follows up with a
bunch of useful ones.
 
L

Lew

javax.swing.JSnarker said:
This should give a type error since neither boolean nor Boolean is
assignable to either int or Integer. Are you implying that it doesn't?
Why not come right out and say exactly what it does?

You're right. Oops. I meant

class Foo
{
public Integer bill;
public int jill = bill;
}

Sorry about that.
 
J

javax.swing.JSnarker

You're right. Oops. I meant

class Foo
{
public Integer bill;
public int jill = bill;
}

Sorry about that.

That one's pretty obvious too: it will throw an NPE when you try to
create an instance, since the reference-typed bill will be null and then
there's an implicit attempt to call intValue() on it.

--
 
J

javax.swing.JSnarker

If the shoe fits ...

It doesn't.

Apparently nobody here has learned their lesson regarding lmgtfy links
being prone to cause fire and explosion. That's two more of those that
I've seen posted to this newsgroup just *today*.

Of course, had I googled the name I would have been unable to make my
little joke -- or my implied but somewhat more serious point that your
post was less than 100% easily readable and understandable because it
used an unfamiliar name without elaboration or explanation.

--
 
L

Lew

If the shoe fits ...

Who said that ignorance is a deficiency? It's the unwillingness to
cure ignorance that is the deficiency.

You called it deficient, snarky one. I didn't.

Ignorance and being untrained are not criticisms of an intellect. The
difference between ignorance and a deficient intellect is that the
former is curable.

My point, which you cutely ignored, is that like any detailed
technical language, the JLS sometimes gets thick, just like your math
or CompSci textbooks did. You seem to be crowing over a so-called
"admission" that the JLS falls into this category. Well, whoopdee-
fricking-doo, it turns out that advance technical material can be
difficult to read!

Have I ever said otherwise? Congratulations, you proved a point with
which I have never disagreed. Good work. Winner! You're a Vatican
assasin!
 
L

Lew

That one's pretty obvious too: it will throw an NPE when you try to
create an instance, since the reference-typed bill will be null and then
there's an implicit attempt to call intValue() on it.

There you go, one of the dangers of autoboxing. Congratulations, you
got it.
 
L

Lew

It doesn't.



Apparently nobody here has learned their lesson regarding lmgtfy links
being prone to cause fire and explosion. That's two more of those that
I've seen posted to this newsgroup just *today*.

Of course, had I googled the name I would have been unable to make my
little joke -- or my implied but somewhat more serious point that your
post was less than 100% easily readable and understandable because it
used an unfamiliar name without elaboration or explanation.

In a community of people who are above-average in education and all
trained to use search engines.

I knew that those not pathologically lazy would look it up.
 
J

javax.swing.JSnarker

Who said that ignorance is a deficiency?

You implied it by using it with a disparaging tone.
Have I ever said otherwise? Congratulations, you proved a point with
which I have never disagreed. Good work. Winner! You're a Vatican
assasin!

What. The. ****.

I notice you've ignored this from my earlier post:

--
 
J

javax.swing.JSnarker

There you go, one of the dangers of autoboxing. Congratulations, you
got it.

What's the danger? "Danger" in this context suggest strange, unexpected,
or "undefined" behavior is possible, or that it invites thread-safety or
exception-safety errors, or is likely to cause cryptic and difficult to
debug problems. NPEs arising from dereferencing null references is
nothing at all strange or surprising though.

--
 
J

javax.swing.JSnarker

In a community of people who are above-average in education and all
trained to use search engines.

I knew that those not pathologically lazy would look it up.

Still missing the point, I see. If you write your posts such that they
aren't understandable without looking things up, then you are failing to
communicate as effectively as you could.

--
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,781
Messages
2,569,619
Members
45,316
Latest member
naturesElixirCBDGummies

Latest Threads

Top