is there any better way to solve this problem?
Write a Java program to rearrange all the elements of an given array of integers so that all the odd numbers come before all the even numbers. import java.util.Arrays; public class Arr_arrange { public static void main(String[] args) { int[] arr = {12,76,89,54,23,93,19}; int[] na = new int[arr.length]; int j = 0; for (int k : arr) { if (k % 2 != 0) { na[j] = k; j++; } } for (int k : arr) { if (k % 2 == 0) { na[j] = k; j++; } } System.out.println("new arrays is : " + Arrays.toString(na)); } } OUTPUT : new arrays is : [89, 23, 93, 19, 12, 76, 54]