Skip to content

Instantly share code, notes, and snippets.

@houssemFat houssemFat/split_join.java
Last active Feb 24, 2016

Embed
What would you like to do?
a simple join at java
/* package whatever; // don't place package name! */
import java.util.Arrays;
import java.util.LinkedHashSet;
import java.util.Set;
/* Name of the class has to be "Main" only if the class is public. */
class Ideone
{
public static void main (String[] args) throws java.lang.Exception
{
char [] charArray = "Hello".toCharArray();
Set<String> strings = new LinkedHashSet<>();
for (char c : charArray) {
strings.add(String.valueOf(c));
}
String out = String.join("-", strings) ;
System.out.println(out);
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.