[android] 文字列をカンマで区切る
文字列をカンマで区切る
str.splitで
String str = "りんご,レモン,すいか,ぶどう"; String[] fruit = str.split(",", 0);
splitの最後の0は切り出す文字列制限=無限
結果
fruit[0] = "りんご"; fruit[1] = "レモン"; fruit[2] = "すいか"; fruit[3] = "ぶどう";
str.splitで
String str = "りんご,レモン,すいか,ぶどう"; String[] fruit = str.split(",", 0);
splitの最後の0は切り出す文字列制限=無限
結果
fruit[0] = "りんご"; fruit[1] = "レモン"; fruit[2] = "すいか"; fruit[3] = "ぶどう";