I have watched videos, searched this websites and many others, but nothing really helps. This is the first time I have used ArrayLists. If I have the ArrayList as String it's fine, but as soon as I set Comment (which is the class) it no longer works. But the tutor has implied that this is how it's meant to be used. I have two other classes that need access to it plus obviously the main method.
Main problem I am having is it won't allow me to add to the arraylist. And I'm stumped and it's probably really simple.
public class Comment {
// somehow need to link it to the game/app
private ArrayList<Comment> Reply = new ArrayList<Comment>();
private String usrComment;
private String usrID;
public Comment() {
}
public Comment(String usrID, String usrComs) {
this.usrComment = usrComs;
this.usrID = usrID;
}
public void addReview(String addRev) {
this.Reply.add(addRev); // not working
}
public void addReply(String addRep) {
Reply.add(addRep); // not working and I cannot figure it out
}
public void printRep() {
for (Comment comment : Reply) {
System.out.println(comment);
}
}
}
Comments.StringtoCommentand vice versa.