
org.sonar.l10n.pmd.rules.pmd.AvoidArrayLoops.html Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of sonar-pmd-plugin Show documentation
Show all versions of sonar-pmd-plugin Show documentation
Sonar-PMD is a plugin that provides coding rules from PMD.
The newest version!
Instead of manually copying data between two arrays, use the efficient Arrays.copyOf or System.arraycopy method instead.
Noncompliant Code Example
int[] a = new int[10];
int[] b = new int[10];
for (int i = 0; i < 10; i++) {
b[i] = a[i];
}
Compliant Solution
int[] a = new int[10];
int[] b;
// Option 1
b = Arrays.copyOf(a, a.length);
// Option 2
System.arraycopy(a, 0, b, 0, a.length);
© 2015 - 2025 Weber Informatics LLC | Privacy Policy