public class Copy {
public static void copy(char[] s, char[] t){
int i=0;
for(i=0; i<s.length; i++){
t[i]=s[i];
}
t[i] = ‘\0‘;
}
public static void main(String[] args) {
char[] s = new char[] {‘h‘,‘e‘,‘l‘,‘l‘,‘o‘,‘,‘,‘w‘,‘o‘,‘r‘,‘l‘,‘d‘,‘!‘};
char[] t = new char[15];
copy(s, t);
for(int i=0;i<t.length ;i++){
System.out.print(t[i]);
}
}
}
时间: 2024-10-12 03:29:42