358 Lotus blogs updated hourly. Who will post next? Home | Downloads | Events | Pods | Blogs | Search | myPL | About 
 
Latest 7 Posts
IBM i 7.2 Technical Overview with TR1
Fri, Dec 12th 2014 58
Notes client with embedded sametime 9 crashes when launched from eclipse
Thu, Nov 6th 2014 226
New "Case of the unexplained" and "Malware hunting" session recordings with Mark Russinovich
Mon, Nov 3rd 2014 368
Recovering from "database is being taken offline and cannot be opened" on Domino Server
Fri, Oct 17th 2014 263
Virtual Control Panel in IBM i Access Client solutions
Tue, Oct 14th 2014 153
How to find the documents which reference a DAOS NLO file.
Tue, Oct 14th 2014 149
Nice Partnership betweeen Apple and IBM in mobile business
Sat, Oct 11th 2014 125
Top 10
New "Case of the unexplained" and "Malware hunting" session recordings with Mark Russinovich
Mon, Nov 3rd 2014 368
Recovering from "database is being taken offline and cannot be opened" on Domino Server
Fri, Oct 17th 2014 263
Notes client with embedded sametime 9 crashes when launched from eclipse
Thu, Nov 6th 2014 226
Show pictures in emails from iPhones as attachments and not as inline images
Wed, Aug 14th 2013 189
Die Cloud und der Browser sind für Enterpriseanwendungen vielleicht doch keine so gute Idee
Mon, Aug 4th 2014 183
Force the Notes client to refresh policies from the server
Thu, Aug 8th 2013 182
Virtual Control Panel in IBM i Access Client solutions
Tue, Oct 14th 2014 153
How to find the documents which reference a DAOS NLO file.
Tue, Oct 14th 2014 149
IBM Notes/Domino 8.5.3 FP6 is available on Fix Central
Wed, Dec 11th 2013 129
Nice Partnership betweeen Apple and IBM in mobile business
Sat, Oct 11th 2014 125


"equal" vs "==" in Java
   

Ein typischer Anfängerfehler in Java ist, zwei Objekte in einer if Klausel mit "==" statt mit .equals() zu vergleichen. Dies ist aber in den meisten Fällen grundfalsch. Das tückische dabei ist, dass der Fehler nicht immer sofort auffällt, da unter manchen Umständen der Vergleich mit "==" auch funktioniert.

Um zu verstehen warum die beiden Vergleiche unterschiedlich sind, muss man zuerst wissen, wie Java eigentlich Objekte verwaltet. Wenn mit new ein neues Objekt erzeugt wird und einer Variable zugewiesen wird, wird nicht das Objekt in der Variable gespeichert, sondern das Objekt wird am Heap (Hauptspeicher) erzeugt und ein Zeiger auf die Stelle im Heap an der das Objekt gespeichert ist, wird der Variable zugewiesen. Man kann sich sozusagen die Variable als einen primitiven Datentyp vorstellen, der eine Referenz auf den Heap speichert. Mehrere Variablen können die selbe Referenz auf das selbe Objekt im Heap zugewiesen haben. Wenn nun mit "==" verglichen wird, wird das Objekt im Heap gar nicht angeschaut, sondern es wird nur verglichen, ob die Variable die gleiche Referenz enthält. Wenn ja wird true zurückgeliefert und wenn nein wird false zurückgeliefert. Ganz anders verhält es sich beim equals(). Hier müssen die Objekte nicht einmal vom gleichen Typ sein, sondern es kommt auf die Implementierung der "equals" Methode an, ob das Ergebnis true oder false ist. Im Normalfall wird man immter mit equals() vergleichen, da ich im Normalfall wissen will, ob es sich um ein logisch gleiches Objekt handelt und nicht um das selbe Objekt. Wenn alles so klar ist, warum funktioniert dann folgender Code:


String test1="Test";
String test2="Test";
System.out.println(test1==test2); //Bitte auf keinen Fall so machen
System.out.println(test1.equals(test2); //So vergleicht man richtig.
Im Normalfall würde man erwarten, da man zwei String Literale hat, dass der erste Vergleich false ergeben würde. Doch die JVM verwendet für Stringliterale einen Cache und so wird der zweite Literal wegoptimiert und beide Variablen verweisen auf das selbe Objekt im String Cache. Nur sollte man sich auf keinen Fall auf das verlassen, da eine andere JVM Implementierung auf diesen Cache eventuell verzichtet, oder der Cache bereits voll ist und dann hat man plötzlich zwei unterschiedliche Objekte und der erste Vergleich ergibt false.

---------------------
http://petterralf.blogspot.com/2012/12/equal-vs-in-java.html
Dec 14, 2012
25 hits



Recent Blog Posts
58


IBM i 7.2 Technical Overview with TR1
Fri, Dec 12th 2014 5:10a   Ralf Petter
The long awaited draft of the redbook "IBM i 7.2 Technical Overview with TR1" has been posted to the IBM redbook site. So if you plan to upgrade to the latest and greatest release of "IBM i" read this fantastic redbook. [read] Keywords: ibm
226


Notes client with embedded sametime 9 crashes when launched from eclipse
Thu, Nov 6th 2014 7:23a   Ralf Petter
I often start my Notes client from eclipse to debug our plugins in the client. I have described how to configure eclipse to start notes from eclipse in an older blog post. Yesterday our Admin has installed the sametime 9.0 embedded client in my Notes installation and after that Notes crashes when started from eclipse with the following error in the error log: Unhandled exception Type=Segmentation error vmState=0x00040000 J9Generic_Signal_Number=00000004 ExceptionCode=c0000005 ExceptionAddress=9 [read] Keywords: admin ibm notes notes client sametime community eclipse
368


New "Case of the unexplained" and "Malware hunting" session recordings with Mark Russinovich
Mon, Nov 3rd 2014 2:20a   Ralf Petter
If you really want to learn how to solve problems in Windows i really recommend to watch the latest versions of this sessions at TechED of Mark Russinovich the creator of the Sysinternals tools. In the Cease of the unexplained session Mark shows you how to analyze program crashes, sluggish performance, blue screens and other windows problems. In the malware hunting session Mark explains how to use the fabulous sysinternals tools to detect and remove malware from your computer. And the bes [read] Keywords: microsoft
263


Recovering from "database is being taken offline and cannot be opened" on Domino Server
Fri, Oct 17th 2014 3:29a   Ralf Petter
Today in the morning many users cannot access the Domino Server because they get the error message "database is being taken offline and cannot be opened". In the Server tasks we see that the DBMT task hangs on a database. Our Domino admin has restarted the server to solve the problem with no success. The databases which are not accessible have a xxx.tmp file with the exact same size as the nsf file. We have tried to remove the xxx.tmp file, but the databases are still offline. Even the normal [read] Keywords: admin agent domino lotus updall database server
153


Virtual Control Panel in IBM i Access Client solutions
Tue, Oct 14th 2014 6:09a   Ralf Petter
Jesse Gorzinski from IBM has posted a nice article on developerworks about the many advantages the Virtual Control Panel in IBM i Access Client solutions have over the old on fro IBM i Access for Windows. If you have not already you should really make the switch to the future of IBM i client connection. [read] Keywords: ibm
149


How to find the documents which reference a DAOS NLO file.
Tue, Oct 14th 2014 1:31a   Ralf Petter
Yesterday i had the problem that a user who got a new replica of his mail file does not get new mails. Every time he start the replication of his mail file he got the error "File does not exist" in the replicator tab. The replication log shows that the replica is sending data to the server, but does not get any data from the server. The error message "File does not exist" on the client does not really help, but there is also an error in the server log which shows the root cause of the pr [read] Keywords: domino lotus application database server
125


Nice Partnership betweeen Apple and IBM in mobile business
Sat, Oct 11th 2014 6:11a   Ralf Petter
Hey IBM really a nice partnership between you and Apple in the mobile business. First IOS release after the announcement of the partnership kills the mobile controls of xPages in Domino and IBM needs three weeks to get a technote out of the door that says that they need additional time to solve the problem with a interim fix. Maybe you should announce a partnership with google in the browser business and a few weeks after that google releases a new Chrome browser which kills your web based prod [read] Keywords: domino ibm xpages apple google mobile




98


Everything you always wanted to know about PTF handling on IBM i but were afraid to ask
Wed, Oct 1st 2014 3:59a   Ralf Petter
In the moment i prepare the image catalogs for PTF installation on our IBM i. When i have searched for some info's on PTF's i have found a really great presentation about PTF Management on the IBM i. So if you want to know how PTF's on the IBM i work and what to do to keep your system running, i really recommend "Managing your IBM i PTF's" from Larry Bolhuis. [read] Keywords: ibm
91


IBM Notes Traveler 9.0.0.1 Interim Fix 7 has been released today
Mon, Sep 15th 2014 5:37a   Ralf Petter
Today the new Interim Fix 7 for Traveler 9.0.0.1 has been released. You can download the new fix on fix central. Up to now the fix list for this Interim fix is not available, but i will update this post when IBM updates the corresponding documentation [read] Keywords: ibm ldd lotus notes traveler
95


IBM Notes Traveler 9.0.1 Interim Fix 6 has been released today
Mon, Sep 15th 2014 5:33a   Ralf Petter
Today the new Interim Fix 6 for Traveler 9.0.1 has been released. You can download the new fix on fix central. Up to now the fix list for this Interim fix is not available, but i will update this post when IBM updates the corresponding documentation [read] Keywords: ibm ldd lotus notes traveler




Created and Maintained by Yancy Lent - About - Blog Submission - Suggestions - Change Log - Blog Widget - Advertising - Mobile Edition