Menu
Question Index
...

Write a program to truncate the excess length in a string and put ellipsis (...) if the size is greater than 20. When truncated, the total length including ellipsis should be 20 characters.

Input Output
Hello Hello
Hello Merit Campus Hello Merit Campus
Hello, How are you doing today? Hello, How are yo...
This is a great day. This is a great day.
Sun rises in the east and sets in the west. Sun rises in the ...
"" EMPTY STRING null



class TruncateToTwentyCharacters
{
    public static void main(String s[])
    {
        String input = "Hello, How are you doing today?";
        
        String result = truncateToTwentyCharacters(input);
        
        System.out.println(result);

    }


    public static String truncateToTwentyCharacters(String input)
    {
    }

}

Doubts

Problems

Topic: Java String substring() method - substring 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