public class Main
/**来自
时 代 J a v a 公 众 号 - N o w J a v a . c o m**/
{
public static void main(String[] args)
{
String s1 = "hello there";
char[] charArray = new char[5];
System.out.printf("s1: %s", s1);
// test length method
System.out.printf("\nLength of s1: %d", s1.length());
// loop through characters in s1 with charAt and display reversed
System.out.printf("%nThe string reversed is: ");/** 来 自 时 代 J a v a**/
for (int count = s1.length() - 1; count >= 0; count--)
System.out.printf("%c ", s1.charAt(count));
// copy characters from string into charArray
s1.getChars(0, 5, charArray, 0);
/**代码未完, 请加载全部代码(NowJava.com).**/
本文系作者在时代Java发表,未经许可,不得转载。如有侵权,请联系nowjava@qq.com删除。