69 668
Assignments Done
Successfully Done
In February 2019

Answer to Question #63823 in Java | JSP | JSF for lama

Question #63823
method shortestWord () that does not accept any parameter and return string these metode should find the shortest word in sentence
please help me in me in my homewoork
Expert's answer
package question63823;

import java.util.*;

public class Question63823 {

static String sentence;

public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
sentence = sc.nextLine();

public static String shortestWord() {
String[] arrayOfWord = sentence.split(" ");
int minLength = Integer.MAX_VALUE;
String result = null;
for (String word : arrayOfWord) {
int tempLength = word.length();
if (tempLength < minLength && word.length() > 0 && Character.isAlphabetic(word.charAt(0))) {
minLength = tempLength;
result = word;
return result;

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!


No comments. Be first!

Leave a comment

Ask Your question

Privacy policy Terms and Conditions