can someone help me understand this code and what each line does public static int getLongestReply(String s) { i

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899603
Joined: Mon Aug 02, 2021 8:13 am

can someone help me understand this code and what each line does public static int getLongestReply(String s) { i

Post by answerhappygod »

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; }
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply