package com.day7.one;
public class StringDemo {
/**
* @param args
* char charAt(int index);获取指定索引位置的字符
* char[] toCharArray():把字符串转成字符数组
*/
//public static char[] c2;//成员变量只需定义就行,系统会默认初始化
public static char c3;//默认初始化为"/u0000"
public static int n;//默认初始化为0
public static void main(String[] args) {
System.out.println(c3);
System.out.println(n);//打印0
String str="abcde";
for (int i=0;i<5;i++)
{
char c=str.charAt(i);
System.out.print(c+" ");
for(int j=0;j<5;j++)
{
char[] c2=new char[5];//局部变量必须显现初始化才能用
c2[j]=str.charAt(j);
}
}
char[] c1=str.toCharArray();
for (int i = 0; i < c1.length; i++) {
System.out.print(c1[i]+" ");
}
}
}