Question: This is a longest word program, in this program I have added (test case1) that is some line work as string and I got

This is a longest word program, in this program I have added (test case1) that is "some line work " as string and I got output : some which is correct .

how do I add another string (test case2) which is "galaxy star" in the program directly , such that both inputs gets executed simultaneously as test case 1 and test case 2 , ( just like its shown in the code below)

This is the code below , its already typed just show me how to add one more string This is a longest word program, in this program I have added

58 59 import java.util.Arrays; 60 public class Main 61 { 62 public static void main(String[] args) { 63 String sInputStr = "some line with text"; 64 65 ProcessString Operation(sInputStr); 66 } 67 68 public static void ProcessStringOperation(String sInputStr) 69 70 String[] words = sInputStr.split(" "); 71 String[] finalWork = sInputStr.split(" ");; 72 73 Arrays.sort(words, (x,y)->Integer.compare(x.length(),y.length())); 74 String sArray = Arrays.deepToString(words).split(",")[words.length-1]; 75 sArray =sArray.replace( sArray.substring(sArray.length()-1), ""); 76 77 for (int i=0; i _ Test Case Output Running test cases... Done

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!