java sort list alphabetically
Assuming that those are Strings, use the convenient static method sort…
java.util.Collections.sort(listOfCountryNames)
java sort list alphabetically
Assuming that those are Strings, use the convenient static method sort…
java.util.Collections.sort(listOfCountryNames)
Arrange words of a sentence in alphabetical order in java
// Arrange words of a sentence in alphabetical order in java
import java.util.Set;
import java.util.StringTokenizer;
import java.util.TreeSet;
public class ArrangeInAlphabeticalOrder
{
public static void main(String[] args)
{
Set set = new TreeSet();
String strInput = "hi all welcome to flower brackets blog";
System.out.println("Before arranging sentence in alphabetical order: " + strInput);
StringTokenizer strToken = new StringTokenizer(strInput," ");
while(strToken.hasMoreElements())
{
set.add(strToken.nextElement());
}
System.out.println("After arranging sentence in alphabetical order: " + set);
}
}
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us