1000 Java Tips E-book sample

1000 Java Ti ps

Let's make thi ngs better!

Alexandre Patchine

Revi ews

" I used good t ips from here when st udied Java" The problem wit h any language it is not enough t o st udy only com m ands or API . You need som e feeling t hat you are com fort able, like at hom e, you know where food where bed. This e- book gave m e such feelings t o Java. Before t hat , even get t ing cert ified, I felt like st ranger in a hot el, but now I am at hom e wit h Java. - Pet er, graphic des "This book has saved m e hours of research while coding Java. From t he obvious t o t he obscure, this book answers the real world questions that bring developm ent to a halt. And the authors really know their stuff. A great help." - Robin Kay from user opinions on CNET about free first edit ion "My 5.5 years Java experience can t o be im proved even m ore! " - Net Ram bler from Europe from user opinions on CNET about free first edit ion "Nice form at t o learn Java. Excellent e- book for developers w ho do not have m ent ors around in the initial stages." From user opinions on CNET about free first edit ion

2

Fo r e w o r d

Hello dear reader! " 1000 Java Tips" is m y collect ion of t ricky quest ions and answers from m y newslet t ers for last four years and answers I gave to people in m y em ails. Let m e ask you a few quest ions:

1. Are you preparing for Java cert ificat ion exam and want t o be sure t hat you will pass it from first at t em pt ? This book gives you real exam ples how t o use Java.

2. Are you looking for a j ob as a Java program m er and want t o be prepared for t he Java interview questions?

3. Are you looking for a good design idea? You have com e t o right place! This e- Book will give you m ore knowledge, bet t er perspect ive t o program m ing and com put er science especially. I t covers wide range of questions. My " 1000 Java Tips" e- book will help you t o underst and Java m uch bet t er and be w ell prepared for your Java Cert ificat ion Exam inat ion. The e- Book is m ade in t he form of quest ions and answers. I included also t he big sect ion of Advanced Java Tips by Dr. Heinz Kabut z w here t opics are bigger. They are well writ t en art icles! Ever y art icle exploring one area and gives you exam ples. This e- book is an easy - t o- navigat e huge collect ion of Java Tips. Easy st yle, right proport ion of hum or and Java let s you read t hem at once, in one breat h!

Aut hor of " 1000 Java Tips" e- book, Alexandre Pat chine.

3

Tabl e of Contents

Reviews............................................................................................................... 2 Foreword ............................................................................................................. 3 Table of Cont ent s ................................................................................................. 4 1. I ntroduction ..................................................................................................... 7 2. Applets ............................................................................................................ 8 3. Databases & Beans ........................................................................................... 9 4. Distributed system s .......................................................................................... 9 5. File Syst em s..................................................................................................... 9 6. Graphics, AWT, Swing ..................................................................................... 10 7. General Java .................................................................................................. 10 8. Java Bugs ..................................................................................................... 119 9. Java Hardware...............................................................................................120 10. Java Tools and Soft ware ...............................................................................120 11. Job, fun ...................................................................................................... 120 12. Miscellaneous ..............................................................................................120 13. Mobile Java ................................................................................................. 121 14. Net working, JSP, Mail... et c. .......................................................................... 121 15. Operat ion Syst em s and Java.......................................................................... 121 16. RMI ............................................................................................................122 17. Security ......................................................................................................122 18. Servlet s, Servers, Mail et c. ............................................................................122 19. Sound, Speech and Mult im edia ......................................................................123 20. String, text, num bers, I / O.............................................................................123 21. Threads ......................................................................................................123 22. Code Exam ples ............................................................................................124 23. More Java Tips by Dr. Heinz M. Kabut z ...........................................................124 ...... [ I ssue 001] - Deadlocks ....................................... Er r or ! Book m a r k not de fine d. ...... [ I ssue 002] - Anonym ous I nner Classes ................. Er r or ! Book m a r k not de fine d. ...... [ I ssue 003] - Logging part 1 ................................. Er r or ! Book m a r k not de fine d. ...... [ I ssue 004] - Logging part 2 ................................. Er r or ! Book m a r k not de fine d. ...... [ I ssue 005] - Dynam ic Proxies - Short Tut orial ....... Er r or ! Book m a r k not de fine d. ...... [ I ssue 006] - I m plem ent at ion code inside int erfaces Er r or ! Book m a r k not de fine d. ...... [ I ssue 007] - j ava.awt .Event Queue ....................... Er r or ! Book m a r k not de fine d. ...... [ I ssue 008] - boolean com parisons........................ Er r or ! Book m a r k not de fine d. ...... [ I ssue 009] - Dept h-first Polym orphism ................. Er r or ! Book m a r k not de fine d. ...... [ I ssue 010] - Writ ing GUI Layout Managers............ Er r or ! Book m a r k not de fine d. ...... [ I ssue 011] - Hooking int o t he shut down call .......... Er r or ! Book m a r k not de fine d. ...... [ I ssue 012] - Set t ing focus t o second com ponent of m odal dialog . Er r or ! Book m a r k not defined.

...... [ I ssue 013a] - Serializing GUI Com ponent s Across Net work ... Er r or ! Book m a r k not defined.

...... [ I ssue 013b] - Follow- up ...................................... Er r or ! Book m a r k not de fine d. ...... [ I ssue 014] - I nsane St rings................................. Er r or ! Book m a r k not de fine d. ...... [ I ssue 015] - I m plem ent ing a Soft Reference based HashMap . Er r or ! Book m a r k not defined.

...... [ I ssue 016] - Blocking Queue ............................... Er r or ! Book m a r k not de fine d. ...... [ I ssue 017a] - Swit ching on Obj ect Handles ........... Er r or ! Book m a r k not de fine d. ...... [ I ssue 017b] - Follow- up ...................................... Er r or ! Book m a r k not de fine d. ...... [ I ssue 018] - Class nam es don't ident ify a class ...... Er r or ! Book m a r k not de fine d. ...... [ I ssue 019] - Finding Lost Fram es ......................... Er r or ! Book m a r k not de fine d. ...... [ I ssue 020] - Serializing Obj ect s I nt o Dat abase ...... Er r or ! Book m a r k not de fine d.

4

...... [ I ssue 021] - Non -virt ual Met hods in Java .............. Er r or ! Book m a r k not de fine d. ...... [ I ssue 022] - Classloaders Revisit ed: "Hot deploy" ... Er r or ! Book m a r k not de fine d. ...... [ I ssue 023] - Socket Wheel t o handle m any client s . Er r or ! Book m a r k not de fine d. ...... [ I ssue 024] - Self- t uning FI FO Queues................... Er r or ! Book m a r k not de fine d. ...... [ I ssue 025] - Final Newslet t er............................... Er r or ! Book m a r k not de fine d. ...... [ I ssue 026] - Package Versioning .......................... Er r or ! Book m a r k not de fine d. ...... [ I ssue 027] - Circular Array List ............................ Er r or ! Book m a r k not de fine d. ...... [ I ssue 028] - Mult icast ing in Java.......................... Er r or ! Book m a r k not de fine d. ...... [ I ssue 029] - Det erm ining Mem ory Usage in Java ... Er r or ! Book m a r k not de fine d. ...... [ I ssue 030] - What do you Prefer? ........................ Er r or ! Book m a r k not de fine d. ...... [ I ssue 031] - Hash, hash, away it goes! ................. Er r or ! Book m a r k not de fine d. ...... [ I ssue 032] - Except ional Const ruct ors - Resurrect ing t he dead .... Er r or ! Book m a r k not defined.

...... [ I ssue 033] - Making Except ions Unchecked ........... Er r or ! Book m a r k not de fine d. ...... [ I ssue 034] - Generic Types wit h Dynam ic Decorat ors ........... Er r or ! Book m a r k not defined.

...... [ I ssue 035] - Doclet s Find Bad Code...................... Er r or ! Book m a r k not de fine d. ...... [ I ssue 036] - Using Unicode Variable Nam es .......... Er r or ! Book m a r k not de fined. ...... [ I ssue 037] - Checking t hat your classpat h is valid .. Er r or ! Book m a r k not de fine d. ...... [ I ssue 038a] - Count ing Obj ect s Clandest inely ........ Er r or ! Book m a r k not de fine d. ...... [ I ssue 038b] - Count ing Obj ect s Clandest inely - Follow- up ..... Er r or ! Book m a r k not defined.

...... [ I ssue 039] - Why I don't read your code com m ent s ... ......... Er r or ! Book m a r k not defined.

...... [ I ssue 040] - Visit ing your Collect ion's Elem ent s ..... Er r or ! Book m a r k not de fine d. ...... [ I ssue 041] - Placing com ponent s on each ot her ..... Er r or ! Book m a r k not de fine d. ...... [ I ssue 042] - Speed- kings of invert ing booleans ..... Er r or ! Book m a r k not de fine d. ...... [ I ssue 043] - Arrgh, som eone want s t o kill m e! ...... Er r or ! Book m a r k not de fine d. ...... [ I ssue 044] - Review: Obj ect - Orient ed I m plem ent at ion of Num erical Met hods . Er r or ! Bookm ark not defined.

...... [ I ssue 045] - Mult i-line cells in t he JTable .............. Er r or ! Book m a r k not de fine d. ...... [ I ssue 046] - "The com piler t eam is writ ing useless code again ..." Er r or ! Book m a r k not defined.

...... [ I ssue 047] - Lack of St ream ing leads t o Scream ing Er r or ! Book m a r k not de fine d. ...... [ I ssue 048] - Review: The Secret s of Consult ing ..... Er r or ! Book m a r k not de fine d. ...... [ I ssue 049] - Doclet for finding m issing com m ent s .. Er r or ! Book m a r k not de fine d. ...... [ I ssue 050] - Com m ent ing out your code? ............. Er r or ! Book m a r k not de fine d. ...... [ I ssue 051] - Java I m port St at em ent Cleanup ........ Er r or ! Book m a r k not de fine d. ...... [ I ssue 052] - J2EE Singlet on ................................ Er r or ! Book m a r k not de fine d. ...... [ I ssue 053] - Chart ing unknown wat ers in JDK 1.4 Part I ....... Er r or ! Book m a r k not defined.

...... [ I ssue 054] - HashMap requires a bet t er hashCode( ) - JDK 1.4 Part I I ............ Er ror ! Bookm ark not defined.

...... [ I ssue 054b] - Follow- up t o JDK 1.4 HashMap hashCode( ) m yst eryEr r or ! Book m a r k not defined.

...... [ I ssue 055] - Once upon an Oak ... ....................... Er r or ! Book m a r k not de fine d. ...... [ I ssue 056] - Shut t ing down t hreads cleanly........... Er r or ! Book m a r k not de fine d. ...... [ I ssue 057] - A Tribut e t o m y Dad, Hans Rudolf Kabut z ......... Er r or ! Book m a r k not defined.

...... [ I ssue 058] - Count ing byt es on Socket s................ Er r or ! Book m a r k not de fine d. ...... [ I ssue 059] - When argum ent s get out of hand....... Er r or ! Book m a r k not de fine d. ...... [ I ssue 059b] - Follow- up t o Loooong St rings .......... Er r or ! Book m a r k not de fine d. ...... [ I ssue 060] - Nulling variables and garbage collect ion ........... Er r or ! Book m a r k not defined.

...... [ I ssue 061] - Double- checked locking .................... Er r or ! Book m a r k not de fine d.

5

................
................

In order to avoid copyright disputes, this page is only a partial summary.

Google Online Preview   Download