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

StringBuilder rather than StringBuffer doesn't execute properly in some case #365

Open
longgt opened this issue Nov 8, 2018 · 1 comment

Comments

@longgt
Copy link

longgt commented Nov 8, 2018

StringBuilder rather than StringBuffer doesn't execute properly in the following case (maybe in for loop)

StringBuffer sb;
for(int i = 0; i < 10; i++) {
  sb = new StringBuffer();
  // Do something
  System.out.println(sb.toString());
}
@Fabrice-TIERCELIN
Copy link
Collaborator

Indeed, this case is not handled. The rule is activated only when the object is instantiated once at declaration.

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

No branches or pull requests

2 participants