-
/*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
-
What you'll learn Understand why version control is a fundamental tool for coding and collaboration Install and run Git on your local ...
-
Python has one of the richest ecosystems of libraries and tools, making it a favorite for developers worldwide. GitHub is the ultimate tre...
-
Prepare for a career as a full stack developer. Gain the in-demand skills and hands-on experience to get job-ready in less than 4 months. ...
-
Explanation of the Code s = 'robot' # Assign the string 'robot' to variable s a, b, c, d, e = s # Unpacking the string ...
-
Python 3.14 is here, bringing exciting new features, performance improvements, and enhanced security. As one of the most anticipated updat...
-
What you'll learn Master the most up-to-date practical skills and knowledge that data scientists use in their daily roles Learn the to...
-
What you'll learn Develop data engineering solutions with a minimal and essential subset of the Python language and the Linux environm...
-
Explanation: Initialization: numbers = [ 2 , 5 , 1 , 3 , 4 ] We define a list numbers containing five elements: [2, 5, 1, 3, 4]. Loop with...
-
Step-by-Step Execution: First Iteration (a = 0) b = 0 → d[0] = 0 b = 1 → d[0] = 1 (overwrites previous value) b = 2 → d[0] = 2 (overwrites...
-
Explanation of print(0.1 + 0.2 == 0.3) In Python, floating-point numbers are represented using binary (base-2) approximation, which can in...
Categories
100 Python Programs for Beginner
(96)
AI
(38)
Android
(24)
AngularJS
(1)
Assembly Language
(2)
aws
(17)
Azure
(7)
BI
(10)
book
(4)
Books
(188)
C
(77)
C#
(12)
C++
(83)
Course
(67)
Coursera
(247)
Cybersecurity
(25)
Data Analysis
(1)
Data Analytics
(2)
data management
(11)
Data Science
(142)
Data Strucures
(8)
Deep Learning
(21)
Django
(16)
Downloads
(3)
edx
(2)
Engineering
(14)
Euron
(29)
Excel
(13)
Factorial
(1)
Finance
(6)
flask
(3)
flutter
(1)
FPL
(17)
Generative AI
(9)
Google
(34)
Hadoop
(3)
HTML Quiz
(1)
HTML&CSS
(47)
IBM
(30)
IoT
(1)
IS
(25)
Java
(93)
Java quiz
(1)
Leet Code
(4)
Machine Learning
(76)
Meta
(22)
MICHIGAN
(5)
microsoft
(4)
Nvidia
(4)
Pandas
(4)
PHP
(20)
Projects
(29)
pyth
(1)
Python
(1002)
Python Coding Challenge
(447)
Python Quiz
(83)
Python Tips
(4)
Questions
(2)
R
(70)
React
(6)
Scripting
(1)
security
(3)
Selenium Webdriver
(4)
Software
(17)
SQL
(42)
UX Research
(1)
web application
(8)
Web development
(4)
web scraping
(2)
0 Comments:
Post a Comment