公共?靜電?作廢?main(String[]?args)?摔投?例外?{
字符串?hellostr?=?“餵?世界?然後呢。妳呢。123456!!!";
//(1)
System.out.println("長度?:?"?+?hello str . length());
//(2)
String[]?helloary?=?hellostr.split("?);
System.out.println("Split?被誰?空格鍵:“);
為了什麽?(int?I = 0;我& lthello ary . length;i++)?{
System.out.printf("%d?%s\n ",我,?hello ary[I]);
}
//(3)
int?位置?=?hello str . index of(" 1 ");
int?lastpostion?=?hello str . index of(" 6 ")+1;
字符串?substr?=?hellostr.substring(位置,?lastposition);
System.out.println("substr?:?1?位置?在?”?+?位置?+?",?6?位置?在?”?+?lastposition);
int?intval?=?integer . parse int(substr);
//(4)
System.out.println("int?價值?是嗎?:"?+?intval);
//(5)
浮動?fval?=?float . parse float(substr);
System.out.println("float?價值?是嗎?:"?+?fval);
}
}