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
1
Expert's answer
2016-12-06T14:34:10-0500
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(); System.out.println(shortestWord()); }
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; } }
Numbers and figures are an essential part of our world, necessary for almost everything we do every day. As important…
APPROVED BY CLIENTS
Finding a professional expert in "partial differential equations" in the advanced level is difficult.
You can find this expert in "Assignmentexpert.com" with confidence.
Exceptional experts! I appreciate your help. God bless you!
Comments
Leave a comment