对不起,如果这是一个愚蠢的问题。我是 Java 新手(来自 PHP 背景)。所以这就是我所拥有的。
String variable = new String("whatever");
//instanceof String == true here
variable = null;
//whereas here instanceof String == false
variable = new Integer(3);// error
将变量设置为 null 是否会删除它的引用,因为我使用对象类型对其进行了实例化?有没有办法可以保留变量名但更改它的数据类型?谢谢