Correct the code to make it compilable. The program should print Passed value: value
Introduction to generic programming
Correct the program
Report a typo
Write a program in Java 17
class Main {
public static void main(String... args) {
// correct the next line
Printer<Integer> printer = new Printer();
// do not change the code below
printer.set("value");
printer.print();
}
}
class Printer<T> {
private T value;
void set(T value) {
this.value = value;
}
void print() {
System.out.println("Passed value: " + value);
}
}
___
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.