java中String的用法

String的用法很活跃,也用到的很多。可以根据自己的需要查询API。这里只有concat和substring,indexof的用法

class TestString
{
	 
	public static void main(String[] args) 
	{
		String s = new String("12cx;x");
		String a = "cxx";
		System.out.println(s);
        System.out.println(a);
        System.out.println(s.indexOf("1"));
        System.out.println(s.concat("陈祥祥"));
		System.out.println(s+"陈祥祥");
        System.out.println(s.substring(0,2));

		String[] arr = s.split(";");  //根据“;”来将s拆分为一个一维数组。
		System.out.println(arr[0]);    //打印数组的第一个元素。


		
	}
}
 
原文地址:https://www.cnblogs.com/shoneworn/p/shoneworn5.html