本帖最后由 cehkongfu 于 2012-10-11 22:57 编辑
class Demo
{
public static void main (String []args){
method ();
char str[]={'a','b','c','d','e'};
method1(str);
}
public static void method(){
String str="abcde";
for(int i = 0;i<str.length();i++){
char c=str.charAt(i);
System.out.println(c);
}
}
public static void method1(char[] str){
for(int start=0,end=str.length-1;start<end;start++,end--){
char tmp= str[start];
str[start]=str[end];
str[end]=tmp;
}
for(char ch:str )
System.out.println(ch);
}
}
|