This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
Hi, Are obj != null and !obj.equals(null) the same ? Sometimes I have the impression that obj != null doesn't work. When I replace the code with !obj.equals(null) it works. I have the impression that if the object is instantiated in the class itself I can use !=. If I call method that returns an object I have to use obj.equals(null) to find out if the object is null, like in: if (!pg.getRectangle.equals(null)) if (pg.getRextangle != null) doesn't seem to work correctly . Anyone who can clarify this ? Stefan
The expression for A would return false. The expression for B would give a null pointer exception. If this does not get at what you mean, please give a concrete example. [ April 27, 2002: Message edited by: John Dale ]