public class Colorpoint{public static void Main (string[] args) {String s = null; System.out.println (S instanceof String); ColorPoint CP = (colorpoint) new Object ();}}
Output what? To compile and pass?
Debugging found that you can javac the past, but Java will output false, and then throw an exception.
public class Colorpoint{public static void Main (string[] args) {System.out.println (New ColorPoint () instanceof String);}}
Output what? Can I compile the past?
Try to find that the compilation is not over.
Import java.util.*;p ublic class Colorpoint{<span style= "White-space:pre" ></span>public static void Main ( String[] args) {<span style= "white-space:pre" ></span>colorpoint cp = (colorpoint) new Point (); <span Style= "White-space:pre" ></span>}}class point{}
Can you compile the past? compilation does not pass.
A few requirements for instanceof
1, when the instanceof do the operand is null, the return value is false,
2. If two operands are classes, one of them must be a subtype of the other
Questions about type conversions
Like Instanceof, when two is a class then one must be another subclass, or it will not compile, and as for conversion, it is the run-time thing.
The mystery of instanceof and type conversion