Get the variable value

Report a typo

Initialize the SoftReference and print the value returned by the get() method.

Sample Input 1:

1995

Sample Output 1:

1995
Write a program in Java 17
import java.util.Scanner;
import java.lang.ref.SoftReference;

public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
Integer num = scanner.nextInt();
// inititalize an instance of SoftReference by passing num to the constructor
SoftReference<Integer> softReference = ...

num = null;

System.out.println(/* print the value here */);
}
}
___

Create a free account to access the full topic