A brief talk on the transformation of Java string, character array, list _java

Source: Internet
Author: User
Tags goto

1. About Java.lang.string.split

The Xxx.split () method splits a string into substrings and then returns the result as an array of strings.

2. Array of string-turn characters

String str = "Aa.png,a2.png,a3.png";

String[] Arraystr =new string[]{};

Arraystr = Str.split (",");

3. Character array goto list

List List = Java.util.Arrays.asList (ARRAYSTR);

4.list conversion to character array

string[] Storestr = List.toarray (New string[list.size ());
public class Splittest {public 
 
  static void main (string args[]) { 
 
    string str = "a1.png,a2.png,a3.png";//Original String 
   
    string[] Arraystr = new string[] {};//character array 
    list<string> list = new arraylist<string> ();//List 
 
    Arra Ystr = Str.split (",");//string-character array 
    list = Java.util.Arrays.asList (ARRAYSTR);//character array goto list 
    string[] Storestr = List.toarray (New String[list.size ());//list to character array// 
 
    output character array value of */For 
    (String s:arraystr) { 
      System.out.println (s); 
 
    } 
    System.out.println ("-------------"); 
    /* Output List Value * * for 
    (String s:list) { 
      System.out.println (s); 
 
    } 
    System.out.println ("-------------"); 
 
    for (String s:storestr) { 
      System.out.println (s); 
 
    } 
    System.out.println ("-------------"); 
  } 

   

The above is a small series for everyone to talk about Java string, character array, List of the transformation of all the content, I hope that we support the cloud Habitat Community ~

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.