I have a bit of code that adds instances of a class to a list. I get a 'local variable may not have been initialized error' when I try to add one item to an ArrayList. I can fix the problem easily by doing this in the declaration:
Point tempPoint1, tempPoint2=null;
...as I'm not a fan of making things point to nothing (seems as bad as not being initialized to me!), is there a 'proper' way to do this or is it a case of refactoring?
Incidentally, the code works properly and, so far as I can tell, there is no possibility of tempPoint2 not being assigned a value before it is added to the list.
TIA
Paul
Point tempPoint1, tempPoint2=null;
...as I'm not a fan of making things point to nothing (seems as bad as not being initialized to me!), is there a 'proper' way to do this or is it a case of refactoring?
Incidentally, the code works properly and, so far as I can tell, there is no possibility of tempPoint2 not being assigned a value before it is added to the list.
TIA
Paul
1