File tree Expand file tree Collapse file tree 1 file changed +36
-0
lines changed Expand file tree Collapse file tree 1 file changed +36
-0
lines changed Original file line number Diff line number Diff line change
1
+ package easy ;
2
+
3
+ import java .util .Arrays ;
4
+
5
+ /**
6
+ * Have the function AlphabetSoup(str) take the str string parameter being passed
7
+ * and return the string with the letters in alphabetical order (i.e. hello becomes ehllo).
8
+ * Assume numbers and punctuation symbols will not be included in the string.
9
+ */
10
+ public class AlphabetSoup {
11
+
12
+ /**
13
+ * Alphabet Soup function.
14
+ *
15
+ * @param str input string
16
+ * @return the string with the letters in alphabetical order
17
+ */
18
+ private static String alphabetSoup (String str ) {
19
+ char [] letters = str .toCharArray ();
20
+ Arrays .sort (letters );
21
+ return String .valueOf (letters );
22
+ }
23
+
24
+ /**
25
+ * Entry point.
26
+ *
27
+ * @param args command line arguments
28
+ */
29
+ public static void main (String [] args ) {
30
+ var result1 = alphabetSoup ("leftfield" );
31
+ System .out .println (result1 );
32
+ var result2 = alphabetSoup ("underworld" );
33
+ System .out .println (result2 );
34
+ }
35
+
36
+ }
You can’t perform that action at this time.
0 commit comments