Question Index

Write a program to create a sentence containing only the shortest words from the given sentence.

Input (String) Output (String)
That man has reached immortality who is disturbed by nothing material. is by
The for statement provides a compact way to iterate over a range of values. a a
Every variable should have datatype like int, boolean etc., int etc
Learn Java with Merit Campus Java with

class CreateSentenceWithShortestWords

{    public static void main(String s[])
        String input = "That man has reached immortality who is disturbed by nothing material.";
        System.out.println("The resultant sentence is : " + getSentenceWithShortestWords(input));


public static String getSentenceWithShortestWords(String inputSentence) {
//Write code here to get sentence containing only shortest words from given sentence

private static int getShortestWordLength(String inputSentence) {
//Write code here to find shortest word length



Topic: Additional String Methods in Java

Read this topic
Take test on this topic

Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App