package com.heima.StringBuffer;
public class Example {
/**
* @param args
*/
public static void main(String[] args) {
String s = "羽毛球-篮球-乒乓球";
System.out.println(s.substring(4));
System.out.println(s.substring(7, s.length()));
String[] sArray = s.split("-");
for (int i = 0; i < sArray.length; i++) {
if(i != sArray.length-1){
System.out.print(sArray[i] + ",");
}else{
System.out.print(sArray[i]);
}
}
}
}
篮球-乒乓球
乒乓球
羽毛球,篮球,乒乓球
|
|