can someone help me understand this code and what each line does public static int getLongestReply(String s) { i
Posted: Sun Jul 03, 2022 9:58 am
can someone help me understand this code and what each linedoes
public static int getLongestReply(String s) { int longestReply = 0; String[] arr =s.split("[!.?]"); for (int i = 0; i <arr.length; i++) { Stringtemp = arr.trim(); String[]words = temp.split(" "); int length= words.length; if (length> longestReply) { longestReply = length; } } return longestReply; }
public static int getLongestReply(String s) { int longestReply = 0; String[] arr =s.split("[!.?]"); for (int i = 0; i <arr.length; i++) { Stringtemp = arr.trim(); String[]words = temp.split(" "); int length= words.length; if (length> longestReply) { longestReply = length; } } return longestReply; }