Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class ReorderSt{
- static String []arr=new String[]{"Technoarck"};
- static int [] index= new int[]{1,0,3,2,5,4,7,6,8};
- static void record(){
- String []temp= new String[arr.length];
- //arr[i] should be present at index[i]
- for (int i = 0; i < arr.length; i++)
- temp[index[i]]=arr[i];
- //copy temp to array
- for (int i = 0; i < temp.length; i++) {
- arr[i]=temp[i];
- index[i]=i;
- }
- }
- public static void main(String[] args) {
- record();
- System.out.println("Recorded array is");
- System.out.println(Arrays.toString(arr));
- System.out.println("modified index array is");
- System.out.println(Arrays.toString(index));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement