New classes added in Collections API for Java 1.6

June 6th, 2008 by Boogie

While going through Whizlab’s questions for Collections & Generics, I found quite a few of questions with NavigableSet, NavigableMap, ConcurrentSkipList, etc.

So I decided I will learn those also for the exam. A good way to start is this link:

http://www.javabeat.net/articles/4-what-is-new-in-java-60-collections-api-1.html

Posted in SCJP, IT | No Comments »

Generics understanding - very concise

June 3rd, 2008 by Boogie

You can find a very concise article about Java Generics on IBM’s website :

http://www.ibm.com/developerworks/library/j-jtp01255.html

 It explains quite nicely why Generics are the way they are. It touches type erasure, covariance, T type contructor, and others ( still reading :) ).

Posted in SCJP, IT | No Comments »

How to change your car door handle

May 31st, 2008 by Boogie

I broke my car door handle. Being an old car I barely found a replacement handle. The guy who sold it to me wasn’t in the mood of changing it also.

So I had to do it. Basically all you need is a screwdriver star shaped and some free time( up to half an hour).

Take all the screws out in order to be able to move the door internal panel. You do not need to remove the window opener, which I guess is more complicated. Also you  will need to remove some internal screws, but with care you can make it, no other tools are needed!

Posted in Uncategorized | No Comments »

Healthy grill pan: aluminium or iron?

May 31st, 2008 by Boogie

Googling didn’t help.

The local supermarket has only aluminium grill pans but on the internet I see much praise for the iron ones.

And I recall hearing something about aluminium not being healthy…

I want to make sure I take a good choice, as I plan to use it a lot. Let’s see what I discover.

 EDIT:

Issue solved, thanks to Cooks illustrated. Read what they have to say, it was what I was looking for in terms of quality:

http://www.cooksillustrated.com/testing.asp?testingid=453&bdc=5436

In terms of material health, I found this very nice article:

http://www.eartheasy.com/article_healthy_cookware.htm

Also health related, about the dangers of aluminium cookware:

http://yourcookwarehelper.com/which-cookware-is-safe-and-healthy/

And finally, for further reading:

http://vegkitchen.com/tips/healthy-cookware.htm

…  1 week later …

So I went for a 30Euros relatively small grill pan (about 50 $ ?). It is made from aluminium, but has an extra coating to protect the aluminium shell from getting penetrated.

My grill pan saves the day( every day I have some raw meat in the fridge). I tried salmon, chicken and other unidentified fish. All cooked good, without oil(well, I added just a little bit, directly on the meat). The cleaning takes 30 seconds, nothing ever sticked on the pan.

Posted in Health | No Comments »

Date, numbers and currencies

April 21st, 2008 by Boogie

Some code snippets for constructing objects of Date, Calendar, DateFormat, NumberFormat, Locale:

Date d = null;

Calendar c = null; DateFormat df =

null;

out.println(“java.util.Date”);

out.println(“java.util.Calendar”);out.println(“java.text.DateFormat”);

 

NumberFormat nf = null;Locale l =

null;

out.println(“java.text.NumberFormat”);

out.println(“java.util.Locale”);

 

d = new Date();

//d = new Date(”2008-08-08″);// at Runtime produces IllegalArgumentException

out.println(“Date contructor With String argument is Deprecated”);

d = new Date(1123923842L);

out.println(“Date contructor With long argument is not deprecated”);

 

//c = new Calendar();// won’t compile

c = Calendar.getInstance();

//c = Calendar.getInstance(new Locale(”"));// at Runtime produces IllegalArgumentException

 

l = new Locale(“ro”);

l = new Locale(“xyzt”);// works, no runtime exception

out.println(“Because a Locale object is just an identifier for a region, \n” +

” no validity check is performed when you construct a Locale”);

l = new Locale(“ro”, “RO”);// language, country

l = new Locale(“ro”, “RO”, “XXX”);// language, country, variant - vendor and browser specific

 

//df = new DateFormat();// won’t compile

df = DateFormat.getInstance();

df = DateFormat.getDateInstance();

//df = DateFormat.getDateInstance(123L);// won’t compile

//df = DateFormat.getDateInstance(123);// at Runtime produces IllegalArgumentException

df = DateFormat.getTimeInstance();

df = DateFormat.getDateInstance(DateFormat.LONG);

df = DateFormat.getTimeInstance(DateFormat.SHORT);

df = DateFormat.getTimeInstance(DateFormat.SHORT, new Locale(“xyz”));// with Locale also

 

//nf = new NumberFormat();// does not compile

nf = NumberFormat.getInstance();

nf = NumberFormat.getNumberInstance();

nf = NumberFormat.getCurrencyInstance();

nf = NumberFormat.getInstance(new Locale(“ro”));

nf = NumberFormat.getNumberInstance(new Locale(“ro”));nf = NumberFormat.getCurrencyInstance(new Locale(“ro”));

Posted in SCJP | No Comments »

Flow control, exceptions and assertions 2

April 20th, 2008 by Boogie

Continuing going through the chapter 5 from the SCJP book, I find :

  • The “Enhanced For Loop”

int[] a = {1,2,3};

for (int n : a)

out.println(“next element: “ + n);

 

int[][] a2 = {{1},{1,2},{3}};

for (int[] n : a2)

out.println(“next element: “ + n);

for (int n : a2[1])

 

out.println(“next element: “ + n);

for (Object n : a2)out.println(“next element: “ + n);

  • Break and Continue statements

//labl1: int a = 1;// does not compile

 

int a;

labl1: a = 1;// OK, you can label this instruction

 

for (int i=1;i < 5; i++){

//break labl1;// does not compile

}

 

LblOuter:

for (int i=1;i < 5; i++){

LblInner:

for (int j=1;j < 5; j++){

if (((i+j)%6) == 0){

out.println(“Breaking out of LblOuter”);break LblOuter;

}

if (((i+j)%3) == 0){

out.println(“Breaking out of LblInner”);break LblInner;

}

out.println(“Going to the next iteration of LblInner”);

continue LblInner;

}

}

    Posted in Uncategorized | No Comments »

    Flow control, exceptions and assertions

    April 20th, 2008 by Boogie

    I got a very low score on the test for flow control, exceptions and assertions. So now I am taking a better look on it and making some  small test programs.

    I’m posting them below, maybe somebody else can find them useful.

    You are free to use them for your own personal development, but note that all content on this site is copyrighted.

    • For statement

    //for (int i = 1, int j = 1; true;){}// does not compile

     

    for (int i = 1, j; i < 1;){i++;}// j is not initialized it’s OK, it is never used !!

     

    for (int i = 1, j = 1; i < 1;){}

     

    int a=2;

    for (int i = 1, j = 1; a < 1;){}// the test can operate on different variables

     

    for (int i = 1; i<1;);

     

    for (int i = 1, j = 1; i < 1 ; out.println(“The increment part” + ” can do something else”)){}

     

    for (;;)out.println(“All parts can be omitted!”);

    • Switch statement

    byte b = 2;

    switch (b){

    case 1: break;

    //case 128: break;// does not compile !

    }

     

    int c = 2;

    switch (c){

    case 1: break;

    case 128: break;// OK

    }

     

    switch (5){// OK

    case 1: break;case 128: break;

    }

     

    switch (5){

    case 1: break;

    //case 1: break;// does not compile !

    }

     

    switch (new Integer(5)){// OK

    case 1: break;

    }

     

    switch (new Byte((byte)5)){// OK

    case 1: break;

    //case 128: break;// does not compile !

    }

     

    switch (5){

    case 1: break;

    case 5: out.println(“5 … & falling through”);

    default: out.println(“not in here”);

    case 6: out.println(“6″);}

    • While statement

    //while (boolean b = false){}// does not compile, has to be declared before !

     

    boolean b;while (b = false){}// OK

    Posted in SCJP | No Comments »

    Kon Tiki - sail on board of a raft

    April 18th, 2008 by Boogie

    From time to time I read some pages from Kon-Tiki: Across the Pacific in a Raft .

    I always stop to look on the images. Not everyday you get to see a man catching a shark with his bare hand, in the middle of the ocean, while on board of a raft!

    Posted in Books | No Comments »

    The Red Queen

    April 18th, 2008 by Boogie

    Recently I finished reading The Red Queen: Sex and the Evolution of Human Nature .

    It’s a very interesting book, I am still trying to see what decisions I can take based on what I found out from it.

    For sure I learned good information about the human nature. Which isn’t at all that pure as we would like to think.

    Posted in Books | No Comments »

    Monthly expense calculator

    April 17th, 2008 by Boogie

    Been reading the The 4-Hour Workweek: Escape 9-5, Live Anywhere, and Join the New Rich book by Tim Ferris.

    I just calculated my monthly expenses, added a buffer of 30% and came up with 2000 Euros ( around 3200 USD). It’s not that much.

    Posted in Books, Life | No Comments »