Java Program to Move All Zeroes to End of Array

preview_player
Показать описание
Write a Java program to move all zeroes to end of array. Given an array of random integers move all zeroes of a given array to the end of an array.

Рекомендации по теме
Комментарии
Автор

Short, to the point, well explained tutorial.

bikramasingh
Автор

int j = 0;
for (int i = 0; i < arr.length; i++) {
if (arr[i] != 0) {

if (i != j) {
int temp = arr[i];
arr[i] = arr[j];
arr[j] = temp;
}
j++; }
}

SahanasAllinOneChannel