public class Dene {
private char ch;
private Dene next;
public Dene(char c) {
this.ch = c;
}
public void add(Dene next) {
this.next = next;
}
public boolean isWriteable(String s) {
if (this.next == null) {
if (s.contains(Character.toString(this.ch))) {
return true;
} else {
return false;
}
} else {
return this.next.isWriteable(s);
}
}
}
public static void main(String[] args) {
Dene d = new Dene('a');
Dene e = new Dene('e');
Dene f = new Dene('f');
d.add(e);
e.add(f);
System.out.println(d.IsWriteable("afb"));
}
IsWriteable gets a string as a parameter and sees recursively if its possible to write that string from the chars which are connected in the linked list.. but it is not working..any ideas?
return this.x.IsWriteable(s);toreturn this.x.isWriteable(s);in my edit, because the first one didn't compile. See if it has anything to do with your problem!