class MyStringBuffer {
//TODO explain: why you would need these data members.
private char[] chars; //character storage.
private int length; //number of characters used
public String toString(){
//TODO
//Hint: just construct a new String from the ‘chars’ data member
//and return this new String – See API online for how create
//new String from char[]
This is only part of the code, I didn't want to post the whole thing. I just to focus on this and then then move on when I fully understand it.
1) What does he mean when he said construct a new String
from the 'chars' data member? I'm confused as to what he wants me to do. Am I suppose to do something with char charAt(int index)
? or something like this: StringBuffer sb = new StringBuffer("test");
?
2) Does construct and create mean the same thing in Java?