package com.day7.one;
public class Demo {
/**
* @param args
*/
public static void main(String[] args) {
String s="abcde";
for(int i=0;i<s.length();i++)
{
char c=s.charAt(i);
System.out.print(c+" ");//输出a b c d e,获取字符串
}
String[] s1={"a","b","c","d","e"};
for(int i=0;i<s1.length;i++)
{
System.out.print(s1[i]+" ");//输出a b c d e,获取字符串数组
}
String[] s2={"abcde"};
System.out.println(s2.length);//输出1,只是长度为1的数组,并不是5
for(int i=0;i<s2.length;i++)
{
System.out.print(s2[i]+" k");//输出abcde k
}
}
}
原文地址:https://www.cnblogs.com/zhujialei123/p/8111364.html
时间: 2024-10-25 01:21:59