Posted in February 15, 2008 ¬ 4:46 amh.Augusto
Two people sent me this code blooper the other day, again, class and parameter names have been changed to protect the identity of the offender(s).
public SomeObject(
boolean lowSetting,
boolean highSetting,
boolean currentSetting,
Color lowColor,
Color highColor,
Color currentColor,
Color otherColor)
{
super();
lowSetting = this.lowSetting;
highSetting = this.highSetting;
[...]
Read the rest of this entry »
Posted in October 17, 2007 ¬ 4:25 pmh.Augusto
This one is fairly easy to catch, but it was a self inflicted code blooper that had me thinking for a bit.
public class Key implements java.io.Serializable
{
String key;
public Key(String key)
{
this.key = key;
}
@Override
public String toString()
{
return [...]
Read the rest of this entry »
Posted in May 4, 2007 ¬ 12:17 amh.Augusto
Today’s code blooper involves a Java object that cannot be instantiated in Java.
I was helping somebody unit test some code and we kept getting a null pointer exception on the constructor. First of all, the object in question had overly complicated constructors. Imagine something like this.
public FruitBasket(){
// Does nothing [...]
Read the rest of this entry »
Posted in January 19, 2007 ¬ 3:36 pmh.Augusto
This is the first entry on a category I’d like to name “Code bloopers”. I recently got a message about a piece of code that was throwing a null pointer, it was basically of this form:
synchronized(this.foobar)
This is an easy one. If you think it’s because “this” is null, you have to go back to [...]
Read the rest of this entry »