Write a method that checks if the object passed to it is null or not. If it is null, the method must print "It's null" and if not it must print "It's an object".
Computer scienceProgramming languagesJavaCode organizationObject-oriented programmingClasses and objectsClasses and members
Objects and their properties
Null or not
Report a typo
Write a program in Java 17
import java.util.Scanner;
class Solution {
public void printIsNull(Object o) {
// write your code here
}
}
// Do not change the code below
class Main {
public static void main(String[] args) {
Solution solution = new Solution();
Scanner scanner = new Scanner(System.in);
while (scanner.hasNextLine()) {
Object obj = "null".equals(scanner.nextLine()) ? null : new Object();
solution.printIsNull(obj);
}
}
}
___
By continuing, you agree to the JetBrains Academy Terms of Service as well as Hyperskill Terms of Service and Privacy Policy.
Create a free account to access the full topic
By continuing, you agree to the JetBrains Academy Terms of Service as well as Hyperskill Terms of Service and Privacy Policy.