Ïë°Ñ×Ö·û´®·´×ÅÊä³ö Óö«Æ´Î÷´ÕµÄ֪ʶÂëÁËÒ»¶Ñ È´×ÜÊÇÅܲ»ÆðÀ´ ÇëÎÊÎÊÌâ³öÔÚÄÄÄØ£¿
ÏÈлл¸÷λpackage demo003;
public class homeW {
public static void main(String[] args) {
String a = "¤³¤ó¤Ë¤Á¤Ï";
char[] arry = a.toCharArray();//°Ñ×Ö·û´®×ªcharÊý×é
System.out.println(arry);//´ò³öÀ´¿´¿´ÊÇ·ñ³É¹¦
for(i = 0, j = arry.length - 1; i < arry.length/2; i ++, j --) {
char temp = "x";
temp = arry;
arry = arry;
arry = temp;
}//Êý×鷴ת
for(i = 0; i < arry.length; i ++) {
System.out.println(arry);
}
}
}
˳±ãÎÊһϠeclipseÔõôµ÷×ÖÌå´óС°¡ ÎÊÌâ³öÔÚÑ»·ÖеıäÁ¿iºÍjûÓнøÐÐÉùÃ÷ºÍ³õʼ»¯¡£ÔÚforÑ»·ÖУ¬Ó¦¸ÃÔÚÑ»·Ç°ÉùÃ÷²¢³õʼ»¯iºÍjµÄÖµ£¬ÈçÏÂËùʾ£º
for(int i = 0, j = arry.length - 1; i < arry.length/2; i ++, j --) {
char temp = arry[ i];
arry[ i] = arry;
arry = temp;
}
´ËÍ⣬»¹ÐèҪעÒ⽫tempµÄ³õʼֵÐÞ¸ÄΪ char temp = arry[ i]; £¬¶ø²»ÊÇ char temp = "x"; ¡£
ÕâÑùÐ޸ĺ󣬴úÂ뽫Äܹ»ÕýÈ·µØ½«×Ö·û´®·´ÏòÊä³ö¡£ isdkz ·¢±íÓÚ 2023-9-6 18:56
ÎÊÌâ³öÔÚÑ»·ÖеıäÁ¿iºÍjûÓнøÐÐÉùÃ÷ºÍ³õʼ»¯¡£ÔÚforÑ»·ÖУ¬Ó¦¸ÃÔÚÑ»·Ç°ÉùÃ÷²¢³õʼ»¯iºÍjµÄÖµ£¬ÈçÏÂËù ...
лÀ² »¹ÊDz»ÊìϤÓï·¨ ²Å³öÕâÖÖ´í »¹°Ù˼²»µÃÆß½ã
Ò³:
[1]