Re: [問題] print char[]問題
※ 引述《walm20 (我要買車啦)》之銘言:
: 這是我看書 自己測試的
: char str1[]={'f','u','c','k',' ','y','o','u'};
: char str2[]=new char [20];
: System.out.println("str1[]="+str1);
: System.arraycopy(str1,0,str2,0,str1.length);
: System.out.println("str2[]="+str2);
: str1[]=[C@6b97fd
: str2[]=[C@1c78e57
: 跟書上寫的 只差 str1的內容而已
: 請問為什麼是這樣結果阿?
你應該做的是去了解為甚麼書上會寫這個範例,
當然去找找勘誤表也是該做的嘗試啦。(有些書會在網路上提供這項資訊)
you can try
System.out.println("str1[]="+ new String(str1));
And you can read the chapter about "String" 、 "Array"
--
String temp="relax"; | Life just like programing
while(buringlife) String.forgot(temp); | to be right or wrong
while(sleeping) brain.setMemoryOut(); | need not to say
stack.push(life.running); | the complier will
stack.push(scouting.buck()); | answer your life
stack.push(bowling.practice()); | Bone everything
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 220.134.27.68
討論串 (同標題文章)
本文引述了以下文章的的內容:
完整討論串 (本文為第 8 之 13 篇):