java - Variable might not have been initialized -
here am, thinking know java, , error variable 'storage' might not have been initialized
. here code:
public class robbleset { private final set<robble> storage; // error occurs here public robbleset() { storage = new hashset<robble>(); } public addrobble(robble r) { storage.add(r); // error occurs here } }
storage
initialized in constructor. gives?
one problem you're not declaring return type addrobble
; need change this:
public addrobble(robble r) {
to this:
public void addrobble(robble r) {
i suspect the problem — compiler thinks addrobble
misnamed constructor, complaining fails initialize storage
— if turns out it's not the problem, it's a problem.
Comments
Post a Comment