Challenge: Filter Failure Messages
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.
- In the
extractFailureLogs()method, loop through thelogsarray and check each message for the presence of the keyword "failure" (case-insensitive, using thetoLowerCase()method). - Count how many messages contain the word "failure" and store the result in a variable
count. - Loop through the
logsarray again, and add only the messages containing "failure" into theerrorLogsarray.
Løsning
solution.java
Tak for dine kommentarer!
single
Spørg AI
Spørg AI
Spørg om hvad som helst eller prøv et af de foreslåede spørgsmål for at starte vores chat
Can you explain this in simpler terms?
What are some examples related to this topic?
Where can I learn more about this?
Awesome!
Completion rate improved to 2.7
Challenge: Filter Failure Messages
Stryg for at vise menuen
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.
- In the
extractFailureLogs()method, loop through thelogsarray and check each message for the presence of the keyword "failure" (case-insensitive, using thetoLowerCase()method). - Count how many messages contain the word "failure" and store the result in a variable
count. - Loop through the
logsarray again, and add only the messages containing "failure" into theerrorLogsarray.
Løsning
solution.java
Tak for dine kommentarer!
single