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 thelogs
array 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
logs
array again, and add only the messages containing "failure" into theerrorLogs
array.
Lösning
solution.java
Tack för dina kommentarer!
single
Fråga AI
Fråga AI
Fråga vad du vill eller prova någon av de föreslagna frågorna för att starta vårt samtal
Can you explain this in simpler terms?
What are the next steps I should take?
Can you provide an example?
Awesome!
Completion rate improved to 2.7
Challenge: Filter Failure Messages
Svep för att visa menyn
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 thelogs
array 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
logs
array again, and add only the messages containing "failure" into theerrorLogs
array.
Lösning
solution.java
Tack för dina kommentarer!
Awesome!
Completion rate improved to 2.7single