数组与字符串
程序员文章站
2024-02-24 22:29:52
...
public class Demo2 {
public static void main(String[] args) {
// TODO Auto-generated method stub
char[] arr = { 'l', 'i', 's', 'h', 'u', 'a', 'i', 'c', 'h' };
for (int i = 0; i < 8; i++) {
System.out.println(arr[i]);
}
String s = str(arr);
System.out.println(s);
}
public static String str(char[] arr) {
String s = " ";
for (int i = 0; i < 8; i++) {
s = s + arr[i];
}
return s;
}
}
转载于:https://my.oschina.net/u/3220534/blog/830869