java中toCharArray方法是做什么用的?
意思是把別的數據轉換成字符數組吧比如說字符串
publicclassreversestring{
publicstaticvoidmain(stringargs[]){
stringoriginalstring;
stringresultstring="";
originalstring=joptionpane.showinputdialog("pleaseinputastring:");
char[]chararray=originalstring.tochararray();
for(inti=chararray.length-1;i>=0;i--){
resultstring+=chararray[i];
}
joptionpane.showmessagedialog(null,resultstring,"reversestring",joptionpane.information_message);
}
}