All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.sonar.l10n.pmd.rules.pmd.AvoidArrayLoops.html Maven / Gradle / Ivy

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