Java可以删除类对象吗?

huangapple go评论71阅读模式
英文:

Can Java delet class object?

问题

有没有办法删除类对象 "obj"?

英文:

My code:

public class Main {
    
    public static void main(String[] args) {
        OuterClass obj = new OuterClass();
        
    }
}

There is a way that i can delet the Class object "obj" ?

答案1

得分: -3

Sure, here's the translated code:

// Disable the option to use obj again

You can do this.

public class Main {
    public static void main(String[] args) {
        { 
            OuterClass obj = new OuterClass();
        }
        // the field obj no longer exists.
        String obj = "hi"; // this works as the previous `obj` doesn't apply here
            
    }
}
英文:

> delet, Disable the option to use obj again

You can do this.

public class Main {
    public static void main(String[] args) {
        { 
            OuterClass obj = new OuterClass();
        }
        // the field obj no longer exists.
        String obj = "hi"; // this works as the previous `obj` doesn't apply here
        
    }
}

huangapple
  • 本文由 发表于 2020年10月1日 01:13:42
  • 转载请务必保留本文链接:https://go.coder-hub.com/64142585.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定