Challenge: Null Reference Handling
Oppgave
Swipe to start coding
Write a method to safely check if a string is null or empty, and return a suitable message for each case.
- If the string is
null, return:Input is null. - If the string is empty, return:
Input is empty. - If the string contains text, return:
Input is: <value>(replace<value>with the actual string value).
Call this method from the main method with at least one example of each case, and print the returned result.
Løsning
solution.java
Alt var klart?
Takk for tilbakemeldingene dine!
Seksjon 2. Kapittel 5
single
Spør AI
Spør AI
Spør om hva du vil, eller prøv ett av de foreslåtte spørsmålene for å starte chatten vår
Awesome!
Completion rate improved to 7.14
Challenge: Null Reference Handling
Sveip for å vise menyen
Oppgave
Swipe to start coding
Write a method to safely check if a string is null or empty, and return a suitable message for each case.
- If the string is
null, return:Input is null. - If the string is empty, return:
Input is empty. - If the string contains text, return:
Input is: <value>(replace<value>with the actual string value).
Call this method from the main method with at least one example of each case, and print the returned result.
Løsning
solution.java
Alt var klart?
Takk for tilbakemeldingene dine!
Seksjon 2. Kapittel 5
single