Nice puzzle. Very mysterious until you spot it.
> I just made this up as a time filler:
Admit it. This is from a real-world scenario. :p
I'll admit I was looking for a feature buried deep in the JLS, only to
discover how mundane the actual error was...
--
Beware of bugs in the above code; I have only proved it correct, not
tried it. -- Donald E. Knuth
Yeah.
-.-
While we're on this subject -- we aren't really, it's just a figure of
speech --, one of my favourites is the following:
<code>
public class Main {
public static void main(String[] ss){
http://java.sun.com/docs/books/jls/third_edition/html/statements.html#14.7
for(int ii = 0; ii < 5; ii++){
System.out.println("README!");
}
}
}
</code>
--
DF.
--
Daniel Pitts' Tech Blog: <http://virtualinfinity.net/wordpress/>
> Easy, a [spoiler deleted]
What? No spoiler alert or ROT-13? Tsk, tsk.
> I just made this up as a time filler:
>
> Can you see anything suspicious in the following
> Java source code without pasting it into an IDE
> or trying to compile it?
>
> Code starts after this colon:
Got that in about three seconds - the "after this colon" remark gives it
away immediately!
We had this problem for real at work recently. I was trying to write a
comment explaining that a document will be classified as XHTML if it has a
type matching */xhtml+xml ...
tom
--
Civis Britannicus sum.
Brilliant! I'm going to be using that ASAP - it'll be a nice trick to play
on my pair-programming partner ...
Isn't one request to read something enough ? :-)
Hey, you try to choose a number between zero and forty-two and we'll see
whether you come up one.
--
DF.
lol. I've actually been bit by a \uxxxx invalid character in a comment
before.
>
> http://java.sun.com/docs/books/jls/third_edition/html/statements.html#14.7
> for(int ii = 0; ii < 5; ii++){
> System.out.println("README!");
See this one I don't get. http: is a label, sure, but why doesn't the
rest fail to parse? The JLS says labels have to be identifiers and this
clearly isn't. The / . and # disqualify it. So I don't get why the
compiler passes it.
JLS says:
Identifier:
IdentifierChars but not a Keyword or BooleanLiteral or
NullLiteral
IdentifierChars:
JavaLetter
IdentifierChars JavaLetterOrDigit
JavaLetter:
any Unicode character that is a Java letter (see below)
JavaLetterOrDigit:
any Unicode character that is a Java letter-or-digit (see
below)
Letters and digits may be drawn from the entire Unicode character set,
which supports most writing scripts in use in the world today, including
the large sets for Chinese, Japanese, and Korean. This allows
programmers to use identifiers in their programs that are written in
their native languages.
A "Java letter" is a character for which the method
Character.isJavaIdentifierStart(int) returns true. A "Java
letter-or-digit" is a character for which the method
Character.isJavaIdentifierPart(int) returns true.
The Java letters include uppercase and lowercase ASCII Latin letters A-Z
(\u0041-\u005a), and a-z (\u0061-\u007a), and, for historical reasons,
the ASCII underscore (_, or \u005f) and dollar sign ($, or \u0024). The
$ character should be used only in mechanically generated source code
or, rarely, to access preexisting names on legacy systems.
The "Java digits" include the ASCII digits 0-9 (\u0030-\u0039).
What is the next two characters after colon ?
Arne
Or, to ask it another way, what acts like whitespace but isn't white?
Oh, right. OK I see it now, thanks guys. :-)
Sure..
> ...
> public class algorithm ...
..should be Algorithm according to the common
nomenclature. For all the rest of this, I would
paste it into an IDE (or rather, TextPad, which is
good enough) to show the problem in the comment).
In any case, since the riddle has been explained
by others, I shall put the 'obvious solution'.
<sscce>
/*
Every algorithm might use
- any other algorithm (in this sense and also in this class)
- the types int, double, boolean
- type conversions between int and double
- arithmetic operations +-*<span>/</span>%
- boolean-arithmetic operations < > <= >= != ==
- boolean operations & | !
- if, while(), restricted switches, ?:
- all interfaces
An algorithm might not explicitly refer to specific classes,
arrays or other types.
*/
/** type matching *<span>/</span>xhtml+xml ... */
class TestJavaDocComment {
}
</sscce>
--
Andrew Thompson
http://pscode.org/
For consistency, I would do:
- arithmetic operations + - * / %
> - boolean-arithmetic operations < > <= >= != ==
> - boolean operations & | !
> - if, while(), restricted switches, ?:
Note that the other operators have spaces between them.
Good point, but would that not also apply to..
> > - boolean-arithmetic operations < > <= >= != ==
> > - boolean operations & | !
> > - if, while(), restricted switches, ?:
..?
How is '?:' used in Java (besides as a String instance)?
In the JLS it is a conditional operator but I thought I remembered from
my C days that that was a ternary operator. I did, K&R page 47.
--
Knute Johnson
email s/nospam/knute2008/
--
Posted via NewsDemon.com - Premium Uncensored Newsgroup Service
------->>>>>>http://www.NewsDemon.com<<<<<<------
Unlimited Access, Anonymous Accounts, Uncensored Broadband Access
> In the JLS it is a conditional operator but I thought I remembered
> from my C days that that was a ternary operator. I did, K&R page 47.
It is *a* ternary operator. It's a common misunderstanding that that
is its name. The expression created using it was called "conditional
expression", but the operator didn't have a name of its own.
K&R 2nd ed, ANSI C, secion 2.11: "Conditional Expression", says:
The /conditional expression/, written with the ternary
operator "?:", provides ...
"Ternary" just means that it takes three operands, just as
multiplication is a *binary* operator. It just happens that the
conditional expression operator is the only ternary operator in
the langauge (and in most languages with syntax derived from C).
In Java, the JLS calls the operator itself the "conditional operator".
/L
--
Lasse Reichstein Nielsen
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
'Faith without judgement merely degrades the spirit divine.'
>public class algorithm { /* todo */ }
You violated the coding convention. That should be Algorithm.
Here is a related one:
/*
When you are done the results will appear in E:\temp\unbroken.txt
*/
--
Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com
I think I don't really understand what you meant, but from the context
I'd guess, that either you missed my smiley, or I miss that invisible
smiley at the end of your line.
My "criticism" on the number of iterations was just a retro-fitted
excuse for placing the "break" with the almost-URL.
Interesting. I chose seventeen, which is not one. I wonder what
results other people get.
"Then shalt thou count to three, no more, no less. Three shall be the
number thou shalt count, and the number of the counting shall be three.
Four shalt thou not count, neither count thou two, excepting that thou
then proceed to three. Five is right out." -- Monty Python and the Holy
Grail
Oops, wrong language. :-)
--
John B. Matthews
trashgod at gmail dot com
home dot woh dot rr dot com slash jbmatthews
Pervert.
--
DF.
> or I miss that invisible
> smiley at the end of your line.
Ah, right, it was implied :).
Just a fit of surrealism. No pun intended.
--
DF.
Ow. Banter hurts.
In the meanwhile, another thought occurred to me: if I had been told
that the number I'm choosing is the number of times I'll be told to
"README!", then I think I'd have chosen one, or zero.
Aaah.. but that's the trick, you see? You have to free your mind of all
worldly concerns. I can tell, you know, for I am in truth... Irma
Malaventura, Prof. em. of Numerology at the University of Wallamaloo.
Now, relax, and try to pick a number at random that matches most closely
the one of your credit card.
--
Irma
Found this one on a t-shirt once....
Stefan Ram wrote:
> I just made this up as a time filler:
>
> Can you see anything suspicious in the following
> Java source code without pasting it into an IDE
> or trying to compile it?
>
> Code starts after this colon:
>
> /*
>
> Every algorithm might use
> - any other algorithm (in this sense and also in this class)
> - the types int, double, boolean
> - type conversions between int and double
> - arithmetic operations +-*/%
> - boolean-arithmetic operations < > <= >= != ==
> - boolean operations & | !
> - if, while(), restricted switches, ?:
> - all interfaces
>
> An algorithm might not explicitly refer to specific classes,
> arrays or other types.
>
> */
>
Oh dear... considering how the intelligence level of security grunts and
pigs altogether makes you wonder whether there is such a thing as an
absolute zero, I'd be careful not to stroll into an airport with such a
shirt. You might get charged with cyberterrorism -- that the T-shirt
contains a virus which makes, uh... some device explode.
... *thinks* ...
Hmm, maybe I should buy my boss one.
--
DF.
> I just made this up as a time filler:
>
> Can you see anything suspicious in the following
> Java source code without pasting it into an IDE
> or trying to compile it?
> - arithmetic operations +-*/%
I would think that the "*/" in the line above would terminate the comment early.
--
Tris Orendorff
[ Anyone naming their child should spend a few minutes checking rhyming slang and dodgy sounding names. Brad and Angelina failed to do this when naming their kid Shiloh Pitt. At some point, someone at school is going to spoonerise her name.
Craig Stark ]