Use System.arraycopy to solve this problem.
/**
* @(#)wsi.java
* @author, Harry Wei.
* @version 1.00 2010-11-15
*/
public class wsi
{
public static void main(String[] args)
{
String a="Hello";
output(a);
}
static void output(String str){
char[] b = new char[5];
System.arraycopy( str.toCharArray(), 0, b, 0, str.length() );
for( int i=0; i<5; i++)
System.out.println(b[i]);
}
}
阅读(670) | 评论(0) | 转发(0) |