JavaPatternMatching/resources/bytecode/javFiles/InstanceOf.jav

18 lines
385 B
Plaintext
Raw Normal View History

2023-08-18 09:35:01 +00:00
import java.lang.Number;
import java.lang.Integer;
import java.lang.Double;
import java.lang.String;
public class InstanceOf {
main(n) {
if (n instanceof Integer i) {
takes(i);
return "Integer";
} else if (n instanceof Double d) {
takes(d);
return "Double";
}
}
takes(i) {} // Should be overloaded
}