-
/*Java Sort String Array ExampleThis Java Sort String Array example shows how to sort an array of Stringsin Java using Arrays.sort method.*/import java.util.Arrays;
public class SortStringArrayExample
{
public static void main(String args[])
{
//String arrayString[] strNames = new String[]{“John”, “alex”, “Chris”, “williams”, “Mark”, “Bob”};
/** To sort String array in java, use Arrays.sort method.* Sort method is a static method. **/
//sort String array using sort methodArrays.sort(strNames);
System.out.println(“String array sorted (case sensitive)”);
//print sorted elementsfor(int i=0; i < strNames.length; i++)
{System.out.println(strNames[i]);}
/** Please note that, by default Arrays.sort method sorts the Strings* in case sensitive manner.** To sort an array of Strings irrespective of case, use* Arrays.sort(String[] strArray, String.CASE_INSENSITIVE_ORDER) method instead.*/
//case insensitive sortArrays.sort(strNames);
System.out.println(“String array sorted (case insensitive)”);//print sorted elements againfor(int i=0; i < strNames.length; i++)
{System.out.println(strNames[i]);}
}}
/*Output of above given Java Sort String Array example would beString array sorted (case sensitive)BobChrisJohnMarkalexwilliamsString array sorted (case insensitive)BobChrisJohnMarkalexwilliams*/
Friday, 13 April 2018
Popular Posts
-
Advantages of Object Oriented Programming Object oriented programming has several advantage to the programmer and user. Through inheri...
-
Build interactive, data-driven websites with the potent combination of open-source technologies and web standards, even if you have only ...
-
What is Python? → Python is an interpreted High level programming Language for General purpose programming. Python is created by Gui...
-
Activity_main.xml File <? xml version= "1.0" encoding= "utf-8" ?> < LinearLayout xmlns: android = &qu...
-
Java :- It is a fast, secure and reliable general purpose computer programming language. Python :- A Readable, efficient and powerfu...
-
Python is a high-level programming language that is widely used in various kinds of programming activities. Python is known for its objec...
-
Business Analytics Definition "Study of business data using statistical technique and programming for creating decision suppo...
-
Variables in R A variables are nothing but reserved memory locations to store values. This means that when you create a variab...
-
Procedure Oriented Programming Language:- High level language such as COBOL , FORTRAN AND C is commonly known as procedure oriented progr...
-
➤Each family of processes has its own set of instructions, the set of instructions are called machine instructions ➤A processor underst...

Categories
Android
(22)
AngularJS
(1)
Assembly Language
(2)
Books
(10)
C
(75)
C#
(6)
C++
(81)
Course
(1)
Data Strucures
(4)
Downloads
(1)
Engineering
(13)
flutter
(1)
FPL
(17)
Hadoop
(1)
HTML&CSS
(38)
IS
(25)
Java
(87)
Leet Code
(4)
PHP
(20)
Projects
(1)
Python
(218)
R
(69)
Selenium Webdriver
(2)
Software
(14)
SQL
(27)

ReplyDeletenice article for beginners.thank you.
javacodegeeks
welookups java