Wednesday, June 25, 2008

FileInputStream is slow

http://bannister.us/weblog/2008/06/22/why-fileinputstream-is-slow/

others
http://www.wbrogden.com/
http://www.ghostganz.com/blog/articles/2008/06/24/tostring-is-evil
http://www.jroller.com/eu/entry/throwng_npe
http://tech.puredanger.com/2008/06/24/performance-testing-tip-keep-a-log/

Java puzzle

Good puzzle...
interface.getSuperClass( ) will return null
as interface allows multiple inherutance

http://tech.puredanger.com/2008/06/24/java-puzzler-interface-super-classes/

Friday, June 6, 2008

Java 5 Oracle driver : bug ?

Nice read
http://www.jroller.com/morisil/entry/can_i_trust_oracle_jdbc

Linked Architecture

good read ...

http://cookiesareforclosers.com/blog/2008/06/linkedin-architecture

Difference between JVM , JRE , JDK

Simple some say ... Tricky as seen by others ... your decision :)
Answer is

JVM : Have you ever seen a software to install JVM ? NO ... Because you cant install it . Its considered to be subpart of JRE. Engineers at sun say its hypothetical Java engine that reads and run byte code.

JRE : = JVM + everything needed to run java program ( or should i say class file )

JDK : = JRE + extra tools needed to make java progran. see figure below.




Can you install JRE without JDK ? yes find them on suns site.

You might as well have observed when installing JDK JRE also gets installed

String Buffer vs StringBuilder vs Concatination Operator +

Run this code ... you will realize using concatination operator is better than stringBuilder
Most of us ( including me ) had the idea that StringBuilder will be fast



long now = System.currentTimeMillis();
for (int i=0; i<10000000; i++) {
String str = "one; two " +
";three four; five; six" +
"seven eight nine ten";
}
long then = System.currentTimeMillis();
System.out.println("+ " + Long.toString(then - now));

now = System.currentTimeMillis();
for (int i=0; i<10000000; i++) {
StringBuilder sb = new StringBuilder(200);
sb.append("one; two ");
sb.append(
";three four; five; six");
sb.append(
"seven eight nine ten");
String str = sb.toString();
}
then = System.currentTimeMillis();
System.out.println("StringBuilder " + Long.toString(then - now));

now = System.currentTimeMillis();
for (int i=0; i<10000000; i++) {
StringBuffer sb = new StringBuffer(200);
sb.append("one; two ");
sb.append(
";three four; five; six");
sb.append(
"seven eight nine ten");
String str = sb.toString();
}
then = System.currentTimeMillis();
System.out.println("String Buffer " + Long.toString(then - now));

Output on my PC was ...

+ 32
StringBuilder 9031
String Buffer 12125

Good Blogs

http://tech.puredanger.com/2008/06/03/favorite-java-resources/
http://www.techper.net/2008/06/03/flex-leads-to-clash-between-java-and-flash-communities/
http://thoughts.bharathganesh.com/2008/06/interesting-leak.html
http://linkmingle.com/user/interview_questions/google_interview_questions
http://jeremymanson.blogspot.com/

Thursday, June 5, 2008

Shutdown Windows using Java

Using JNI for it may be an overkill ...


may try

String command = ""; ( click here for shutdown_command )
Process child = Runtime.getRuntime().exec(command);


Or may be try one of these ...
Try one of these (they've both worked, but there might be problems with one - too long ago, don't remember, though )

C:\WINDOWS\RUNDLL32.EXE SHELL32.DLL,SHExitWindowsEx 1
C:\WINDOWS\RUNDLL32.EXE user,exitwindows

All Head First Series eBooks

This is an outdated post
please use http://it-ebooks.info/ or http://en.booksee.org/ to get any ebook you want

For those of you ... who like to collect eBooks ...
Heres the BAAP of all eBooks you collected so far

and above all most of them don't require password ...

Save the links ... as i may delete the post soon ... :)

I couldnt find password less links for ... "Head First Ajax" may be someone can help me with that ....

cheerz !!

More links

http://ebooksresource.wordpress.com/category/design-pattern/
http://martinfowler.com/books.html#eaa
http://knowfree.net/

Is Java Pass by value or pass by reference

Congratulations .... you are the 99,99,999 person to ask that ... click "here" to clain your prize.... ;-)
Let me see .. whats the correct ans....
Some of you may say its "pass by value for primitive data types and pass by reference for objects" ... hmmmm wrong ... actually the intellignet lot ( at least the booky's ) would say "java is pass by value for primitive types and passes refernce by value for objects.. so java is pass by value"... correct buddy ..... you the man !!

BUT ... thats incomplete my friend ... complete answer is .... java is pass by value for primitive types , passes reference by value for object types ... and when passing objects to remote method (ie RMI) its pass by object copy NOT reference copy.

Tuesday, June 3, 2008