private String blogPost;
public Week5() {
blogPost = "";
}
public Week5(String a){
blogPost=a;
}
public setPost(String newPost){
blogPost=newPost;
}
public String toString() {
return blogPost;
}
}
In the main of another method:
Week5 post = new Week5();
post.setPost("Constructors and methods kind of annoy me. Particularly, initialization constructors and setVariable modifier methods seem redundant to me. I mean, they'll be both really helpful once we need to change the values of things mid program, but as it is they just take up more space. You have to input variable values anyways, so you might as well just have a default constructor and prompt the user to input values for use in the modifier methods, though that won't help if you need a predetermined set of values. There's nothing wrong with them, its just irritating to have to use them when they aren't necessary to the program just yet. Maybe that's just me being lazy.");
System.out.println(post);
No comments:
Post a Comment