FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
codeql/java/ql/src/Performance/InefficientPrimConstructor.java at main · github/codeql · GitHub
github
codeql
Repository navigation
Code
Issues
1k
(1k)
Pull requests
474
(474)
Discussions
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
codeql
/
java
/
ql
/
src
/
Performance
/
InefficientPrimConstructor.java
Copy path
More file actions
More file actions
Latest commit
History
History
History
18 lines (17 loc) · 435 Bytes
Breadcrumbs
codeql
/
java
/
ql
/
src
/
Performance
/
InefficientPrimConstructor.java
Copy path
File metadata and controls
18 lines (17 loc) · 435 Bytes
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
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
));
}
}
Back
|
FazBrowse Home
|
New Git URL