Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

原来一直理解错了intern,建议可以把案例改成这个 #7

Open
H-Kcloud opened this issue Sep 2, 2021 · 2 comments
Open

Comments

@H-Kcloud
Copy link

H-Kcloud commented Sep 2, 2021

public class Intern {
public static void main(String[] args) {
String s = new String("2");
String s2 = "2";
s.intern();
System.out.println( s == s2); // false
System.out.println( s.intern() == s2); // true
}
}

@cosen1024
Copy link
Owner

感谢,后面考虑加上

@cosen1024
Copy link
Owner

cosen1024 commented Oct 17, 2021 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants