1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
qaws [65]
3 years ago
13

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".

Complete the method below. Your implementation should conform to the example above.

public static void longestStreak(String str)
Computers and Technology
1 answer:
Gelneren [198K]3 years ago
3 0

public class JavaApplication72 {

   public static void longestStreak(String str){

       char prevC = '_';

       String largest = "";

       String txt = "";

       for (int i = 0; i < str.length(); i++){

           char c = str.charAt(i);

           if (c != prevC){

               txt = "";

           }

           txt += c;

           if (txt.length() > largest.length()){

                   largest = txt;

           }

           

           prevC = c;

       }

       System.out.println(largest.charAt(0)+" "+largest.length());

   }

   public static void main(String[] args) {

       longestStreak("CCAAAAATTT!");

   }

   

}

You might be interested in
What are voter purges
diamong [38]

Answer:

Voter registration lists, also called voter rolls, are the gateway to voting because a citizen typically cannot cast a vote that will count unless his or her name appears on the voter registration rolls. State and local officials regularly remove—or purge—citizens from voter rolls. In fact, 39 states and the District of Columbiareported purging more than 13 million voters from registration rolls between 2004 and 2006.

Explanation:

7 0
4 years ago
Carlos owns a hardware store. He currently is not using any software to track what he has in the store. In 1–2 sentences, descri
Tresset [83]

Carlos Should use a Security Camera to keep track of his physical hardware. Carlos can then use a computer to monitor the security cameras.

7 0
4 years ago
Read 2 more answers
1. What does a network allow computers to share?
Veronika [31]

Answer:

1. B 2. D

Explanation:

If computers share processing power, it is just a larger computer.

8 0
3 years ago
Site won't let me log in and is glitching? Is rainly down?
yarga [219]

Answer: Somewhat.

Explanation: Try refreshing your pages, or reopening your browser.

3 0
3 years ago
Read 2 more answers
You have heard that the Linux distribution your are going to install to run a new application runs best on a RISC architecture.
Artyom0805 [142]

Answer:

SPARC .

Explanation:

When the user has understood they're required to install the linux distribution to set up a specific program works better on such a RISC architecture. SPARC must therefore find the device from which it would work that following distribution for the Linux. It is a RISC and ISA that was previously designed through both Fujitsu and Sun.

6 0
3 years ago
Other questions:
  • Name some of the file extensions for images and provide more information about one or two of them.
    12·1 answer
  • Which of the following types of access controls do not describe a lock? (a)- Directive (b)- Physical (c)- Preventative (d)- Dete
    8·1 answer
  • Karen thinks she should go out with Blane, an unattractive, social misfit, because “If I don’t go out with him, people will thin
    7·1 answer
  • The following code accomplishes which of the tasks written below? Assume list is an int array that stores positive int values on
    9·1 answer
  • What is the FTC used car rule
    12·1 answer
  • With a presentation open, you can hover your mouse pointer over a design theme on the Design tab, and PowerPoint will display th
    14·1 answer
  • Does anyone know what to do when brainly won't let you answer questions? I click on answer question and then it just sits there
    15·2 answers
  • What is the reason for taking care of design a good computer human interface ​
    9·2 answers
  • How to change the microsoft word pages to black background
    8·1 answer
  • What is contained in the Open Files section of Shared Folders? ​
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!