-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathArr_Aft_Last_ten.java
More file actions
35 lines (19 loc) · 856 Bytes
/
Copy pathArr_Aft_Last_ten.java
File metadata and controls
35 lines (19 loc) · 856 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import java.util.*;
import java.util.*;
public class Arr_Aft_Last_ten{
public static void main(String[] args) {
int[] array_nums = {11, 10, 13, 10, 45, 20, 33, 53};
int result = 0;
System.out.println("Original Array: "+Arrays.toString(array_nums));
int l = array_nums.length - 1;
int[] new_array;
// Find the last occurrence of 10 in the array
while(array_nums[l] != 10)
l--;
// Create a new array with elements after the last 10
new_array = new int[array_nums.length - 1 - l];
for(int i = l + 1; i < array_nums.length; i++)
new_array[i - l - 1] = array_nums[i];
System.out.println("New Array: "+Arrays.toString(new_array));
}
}