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[]
これはコードの一部にすぎません。すべてを掲載するつもりはありません。私はこれに集中し、完全に理解したら次に進みます。
String
1) 「chars」データメンバーから新しいものを構築すると彼が言ったとき、彼はどういう意味ですか? 彼が私に何をしたいのか、私は混乱しています。私は何かをすることになっていchar charAt(int index)
ますか?またはこのようなもの:StringBuffer sb = new StringBuffer("test");
?
2) Java では、construct と create は同じ意味ですか?