Cursusinhoud
Java Basics
Java Basics
Challenge: Filter Failure Messages
Taak
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.
- Loop through the
logs
array and check each message for the presence of the keyword "failure" (case-insensitive). - 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.
Oplossing
solution
Was alles duidelijk?
Bedankt voor je feedback!
Sectie 5. Hoofdstuk 4
Challenge: Filter Failure Messages
Taak
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.
- Loop through the
logs
array and check each message for the presence of the keyword "failure" (case-insensitive). - 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.
Oplossing
solution
Was alles duidelijk?
Bedankt voor je feedback!
Sectie 5. Hoofdstuk 4