Question
The method longestStreak is intended to determine the longest substring of consecutive identical characters in the parameter str and print the result. For example, the
The method longestStreak is intended to determine the longest substring of consecutive identical characters in the parameter str and print the result.
For example, the call longestStreak("CCAAAAATTT!") should print the result "A 5" because the longest substring of consecutive identical characters is "AAAAA".
Write the code segment to be used in the body of the method below. The parameter str is a properly initialized String variable. Your implementation should conform to the example above.
public static void longestStreak(String str)
Arrays can't be used to answer this question
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started