問題:
I am new in Java although had a good experience in PHP, and looking for perfect replacement for explode and implode (available in PHP) functions in Java.我是 Java 新手,儘管在 PHP 方面有很好的經驗,並且正在尋找 Java 中爆炸和內爆(在 PHP 中可用)函數的完美替代品。
I have Googled for the same but not satisfied with the results.我用谷歌搜索了相同的但對結果不滿意。 Anyone has the good solution for my problem will be appreciated.任何人對我的問題有好的解決方案將不勝感激。
For example:例如:
String s = "x,y,z";
//Here I need a function to divide the string into an array based on a character.
array a = javaExplode(',', s); //What is javaExplode?
System.out.println(Arrays.toString(a));
Desired output:期望的輸出:
[x, y, z]