Run Code
|
API
|
Code Wall
|
Users
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Print Longest String
class Rextester { public static void main(String args[]) { String input = "Cheese Pepperoni Olives Armagggeddonh"; String [] a = input.split(" "); int maxLength = 0; String longestString = null; for (String s : a) { if (s.length() > maxLength){ maxLength = s.length(); longestString = s; } } System.out.println("Longestn string: "+ longestString); } }
run
|
edit
|
history
|
help
0
Please
log in
to post a comment.
Relation
first activity
Filter Iterator
calc exp
teat2
bubble sort
t
HelloWorld2
apple1
쓰레드 critical section
Please log in to post a comment.