+ 2
Why We Use Join Method In Java .?
Please help me to figure out..
4 Answers
+ 5
Yes, it basically converts arrays to strings (and then to "P P A P" fruits)⊠^_^
+ 3
If you have an array, say, arr = ["Apple", "pen"], array.join(" ") will give you "Apple pen". ["Apple", "pen", "pineapple", "pen"].join("-") will result in "Apple-pen-pineapple-pen".
The join() method is used when certain methods, like sort(), which is only available for arrays, cannot be used on strings.
+ 2
thanks ;_;
the example is awesome đž
+ 2
If you have a string, and you want to let's say sort the characters, you can split the string with .split("") into arrays and use those methods only available for arrays.