Question Index

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

Input (Sentence) Output (Sentence)
Hello 12345, how are you dude. Hello
External nature is only internal nature writ large. External internal
In one word, this ideal is that you are divine. divine
You cannot believe in God until you believe in your self. believe believe
Merit Campus can be reached at 8500622255 reached

class CreateSentenceWithLongestWords

{    public static void main(String s[])
        String input = "You have to grow from the inside out. None can teach you, none can make you spiritual. There is no other teacher but your own soul.";
        System.out.println("The resultant sentence is: " + getSentenceWithLongestWords(input));


public static String getSentenceWithLongestWords(String inputSentence) {
//Write code here to get sentence containing only longest words from given sentence.

private static int getLongestWordLength(String inputSentence) {
//Write code here to find longest 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