Menu
Question Index
...

Write a program to sort the given string array by using bubble sort with the help of compareTo method.

Input (String[]) Output (String[])
{'Hello', 'to', 'java', 'world'} {'Hello', 'java', 'to', 'world'}
{'an', 'indian', 'am', 'I'} {'I', 'am', 'an', 'indian'}
{'good', 'I', 'am', 'girl'} {'I', 'am', 'girl', 'good'}
{'Sun', 'raises', 'east', 'in', 'the'} {'Sun', 'east', 'in', 'raises','the'}
{'Computer', 'mouse', 'keyboard', 'laptop'} {'Computer', 'keyboard', 'laptop', 'mouse'}



class ComparingStringsWithCompareTo
{
    public static void main(String s[])
    {
        String stringArray[] = {"Hello", "to", "java", "world"};
        String[] sortingStringArray = getSortingStringArray(stringArray);
        for (String str : sortingStringArray)
        System.out.print(str + ", ");

    }


    public static String[] getSortingStringArray(String[] stringArray) {
    }

}

Doubts

Problems

Topic: Java String Arrays - String Arrays In Java

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App