Last active
February 24, 2016 14:23
-
-
Save houssemFat/bfcccf9f64e315550ac7 to your computer and use it in GitHub Desktop.
a simple join at java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* 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