Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Lære Challenge: Filter Failure Messages | String
Java Basics

bookChallenge: Filter Failure Messages

Opgave

Swipe to start coding

Imagine you have a list of system messages, and you need to extract only those containing the word "failure".

Write a program that creates a new array with only these messages and then prints them to the console.

  1. In the extractFailureLogs() method, loop through the logs array and check each message for the presence of the keyword "failure" (case-insensitive, using the toLowerCase() method).
  2. Count how many messages contain the word "failure" and store the result in a variable count.
  3. Loop through the logs array again, and add only the messages containing "failure" into the errorLogs array.

Løsning

solution.java

solution.java

Var alt klart?

Hvordan kan vi forbedre det?

Tak for dine kommentarer!

Sektion 5. Kapitel 4
single

single

Spørg AI

expand

Spørg AI

ChatGPT

Spørg om hvad som helst eller prøv et af de foreslåede spørgsmål for at starte vores chat

close

Awesome!

Completion rate improved to 2.7

bookChallenge: Filter Failure Messages

Stryg for at vise menuen

Opgave

Swipe to start coding

Imagine you have a list of system messages, and you need to extract only those containing the word "failure".

Write a program that creates a new array with only these messages and then prints them to the console.

  1. In the extractFailureLogs() method, loop through the logs array and check each message for the presence of the keyword "failure" (case-insensitive, using the toLowerCase() method).
  2. Count how many messages contain the word "failure" and store the result in a variable count.
  3. Loop through the logs array again, and add only the messages containing "failure" into the errorLogs array.

Løsning

solution.java

solution.java

Switch to desktopSkift til skrivebord for at øve i den virkelige verdenFortsæt der, hvor du er, med en af nedenstående muligheder
Var alt klart?

Hvordan kan vi forbedre det?

Tak for dine kommentarer!

close

Awesome!

Completion rate improved to 2.7
Sektion 5. Kapitel 4
single

single

some-alt