java如何将字符串保存在数组中,然后输出

解决方案 »

  1.   

    夜深人静的。。 String[] strs = { "abc", "panda", "cat", "123" };
    System.out.println(Arrays.toString(strs));
      

  2.   

    或者for each语句
    String[] strs = { "abc", "panda", "cat", "123" };'};
    for(String s:strs){
         System.out.println(s);
    }
      

  3.   

    是把字符串转化为char数组还是什么?如果是转换为char数组的话用这个方法toCharArray();
      

  4.   

    String本身有個轉為char[]的方法,另外那個意思的話樓上也說了
      

  5.   


    public class Exe 
    {

    public static void main(String args[])
    {
     
         String[] str= { "abc", "panda", "cat", "123" };
    for(int i=0;i<str.length;i++)
    {
            System.out.println(str[i]);
    }
    }
    }
      

  6.   

    String应该有个split方法,可以把String转成String的数组public String[] split(String regex)Splits this string around matches of the given regular expression. 
    This method works as if by invoking the two-argument split method with the given expression and a limit argument of zero. Trailing empty strings are therefore not included in the resulting array. The string "boo:and:foo", for example, yields the following results with these expressions: Regex Result 
    : { "boo", "and", "foo" } 
    o { "b", "", ":and:f" } 
    Parameters:
    regex - the delimiting regular expression 
    Returns:
    the array of strings computed by splitting this string around matches of the given regular expression 
      

  7.   

    public class MyJava { 
        public static void main( String args[] ) {     String[] str= { "12", "34", "56", "78" }; 
        int i = 0;
       for( i=0 ; i <= str.length - 1 ; i++)  
          System.out.println( str[i] );  

      

  8.   

    大家搞明白lz的意思了吗?先要把字符串放到数组里,然后再输出。
    下例供参考public class numTest {
      public static void main(String args[]) { 
    String str = "aaa";
    char [] strArr = str.toCharArray();
    for(int i = 0;i<strArr.length;i++) {

    System.out.println("output:" + strArr[i]);

    }

      } 
    }