-
/*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
-
Deep learning is at the heart of modern Artificial Intelligence — powering technologies like chatbots, recommendation systems, image recog...
-
Explanation: ๐น Step 1: Create List x = [1,2,3] A list x is created ๐ Values inside list: 1, 2, 3 ๐น Step 2: Understand sum() Function su...
-
Explanation: ๐น Step 1: Understand Boolean Values in Python In Python, booleans are treated like integers: True = 1 False = 0 ๐น Step 2: R...
-
Explanation: ๐น Step 1: Create Tuple x = (1,[2,3]) x is a tuple (immutable) Inside tuple: 1 → integer [2,3] → mutable list ๐น Step 2: Appl...
-
When people think about data science, they often focus on tools like Python, machine learning models, or deep learning frameworks. But beh...
-
Code Expanation: ๐น Step 1: Create List x = [0, 1, 2] A list x is created ๐ Elements: 0, 1, 2 ๐น Step 2: Understand all() Function all(x)...
-
๐ Day 30/150 – Factorial of a Number in Python The factorial of a number means multiplying all positive integers from 1 to n . Example: 5...
-
There are 4 modules in this course AI is not only for engineers. If you want your organization to become better at using AI, this is the c...
-
๐ Day 34/150 – Armstrong Number in Python An Armstrong number is a number that is equal to the sum of its own digits raised to the power...
-
๐ Day 31/150 – Fibonacci Series in Python The Fibonacci series is a sequence where each number is the sum of the previous two numbers. ...
Categories
100 Python Programs for Beginner
(119)
AI
(255)
Android
(25)
AngularJS
(1)
Api
(7)
Assembly Language
(2)
aws
(29)
Azure
(10)
BI
(10)
Books
(262)
Bootcamp
(11)
C
(78)
C#
(12)
C++
(83)
Course
(87)
Coursera
(300)
Cybersecurity
(30)
data
(5)
Data Analysis
(32)
Data Analytics
(22)
data management
(15)
Data Science
(354)
Data Strucures
(17)
Deep Learning
(159)
Django
(16)
Downloads
(3)
edx
(21)
Engineering
(15)
Euron
(30)
Events
(7)
Excel
(19)
Finance
(10)
flask
(4)
flutter
(1)
FPL
(17)
Generative AI
(73)
Git
(10)
Google
(51)
Hadoop
(3)
HTML Quiz
(1)
HTML&CSS
(48)
IBM
(42)
IoT
(3)
IS
(25)
Java
(99)
Leet Code
(4)
Machine Learning
(293)
Meta
(24)
MICHIGAN
(5)
microsoft
(11)
Nvidia
(8)
Pandas
(14)
PHP
(20)
Projects
(33)
pytho
(1)
Python
(1335)
Python Coding Challenge
(1132)
Python Mathematics
(1)
Python Mistakes
(51)
Python Quiz
(492)
Python Tips
(5)
Questions
(3)
R
(72)
React
(7)
Scripting
(3)
security
(4)
Selenium Webdriver
(4)
Software
(19)
SQL
(49)
Udemy
(18)
UX Research
(1)
web application
(11)
Web development
(8)
web scraping
(3)

0 Comments:
Post a Comment