Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@houssemFat
Last active February 24, 2016 14:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save houssemFat/bfcccf9f64e315550ac7 to your computer and use it in GitHub Desktop.
Save houssemFat/bfcccf9f64e315550ac7 to your computer and use it in GitHub Desktop.
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