-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patharray_4.java
More file actions
21 lines (17 loc) · 492 Bytes
/
array_4.java
File metadata and controls
21 lines (17 loc) · 492 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
//Seprate array on basic on Odd and Even numbers.
public class array_4{
public static void main(String args[]){
int a[]= {1,2,3,4,5,6,7,8,9,10};
int arr1[] = new int[a.length];
int arr2[] = new int[a.length];
int count1 =0, count2=0;
for(int i=0; i<a.length; i++){
if(a[i]%2!=0)
arr1[count1++] = a[i];
else
arr2[count2++] = a[i];
}
for(int j=0, k=0; j<count1 || k<count2; j++, k++ )
System.out.println(arr1[j]+" "+arr2[k]);
}
}