Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Lära Challenge: Null Reference Handling | Reference Types and Strings
Java Data Types

bookChallenge: Null Reference Handling

Uppgift

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

solution.java

Var allt tydligt?

Hur kan vi förbättra det?

Tack för dina kommentarer!

Avsnitt 2. Kapitel 5
single

single

Fråga AI

expand

Fråga AI

ChatGPT

Fråga vad du vill eller prova någon av de föreslagna frågorna för att starta vårt samtal

Suggested prompts:

Can you explain this in simpler terms?

What are the main takeaways from this?

Can you give me an example?

close

Awesome!

Completion rate improved to 7.14

bookChallenge: Null Reference Handling

Svep för att visa menyn

Uppgift

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

solution.java

Switch to desktopByt till skrivbordet för praktisk övningFortsätt där du är med ett av alternativen nedan
Var allt tydligt?

Hur kan vi förbättra det?

Tack för dina kommentarer!

Avsnitt 2. Kapitel 5
single

single

some-alt