Posts Tagged ‘fun’

Fun with Java's syntax !

octobre 23, 2009 Laisser un commentaire

Have you ever prepared a certification ?

Well, for me, it’s the first time, and it proves a very nice occasion to learn stuff you should never do and hopefully will never meet in real code. Still, it’s fun like hell 🙂

So, what am I speaking about ?

Well, stuff like these :

class ExtractsFromTheExams
int[] array[]; // such a nice array declaration

String fooArray[] = new String[]
{ "a", "b", }; // yes, this last comma is fine

String bla = new String[]
{ "foo", "bar", }[1]; // seen in some tests...

Object a\u0001; // readable like hell

public class A // some sample class are very clear

public transient String foo;
Bar aBar = new Bar(10);
static Integer nb = 10;

public static void main(final String[] args)
A a1 = new A();
A a2 = a1;
a1.nb = 0;
System.out.println(++a2.nb);// BTW : what to expect from it ? Will
// this class even compile ?

class Bar

public Bar(final int i)
class Huh{
char A = '\u000A' ;// this one for the end. Try compiling it...

Well, don’t understand me wrong, I appreciate working on this certification. Really. The unclear samples are made to make the reader think twice… And I’m pretty sure anyone having tried to figure out these lines above will have read some of them twice. Furthermore, it’s funky only from time to time, it can also be interesting. Overall, this in depth exploration of Java is valuable, even if mostly on corner cases.


Étiquettes : , , ,

Nice jQuery plugin


Crazy framework !

Étiquettes : , , ,
%d blogueurs aiment cette page :