mirror of
https://github.com/github/codeql.git
synced 2025-12-24 20:56:33 +01:00
18 lines
435 B
Java
18 lines
435 B
Java
public class Account {
|
|
private Integer balance;
|
|
public Account(Integer startingBalance) {
|
|
this.balance = startingBalance;
|
|
}
|
|
}
|
|
|
|
public class BankManager {
|
|
public void openAccount(Customer c) {
|
|
...
|
|
// AVOID: Inefficient primitive constructor
|
|
accounts.add(new Account(new Integer(0)));
|
|
// GOOD: Use 'valueOf'
|
|
accounts.add(new Account(Integer.valueOf(0)));
|
|
// GOOD: Rely on autoboxing
|
|
accounts.add(new Account(0));
|
|
}
|
|
} |