Advertisement
Guest User

Untitled

a guest
Aug 18th, 2019
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.73 KB | None | 0 0
  1. class ReorderSt{
  2. static String []arr=new String[]{"Technoarck"};
  3. static int [] index= new int[]{1,0,3,2,5,4,7,6,8};
  4.  
  5. static void record(){
  6. String []temp= new String[arr.length];
  7. //arr[i] should be present at index[i]
  8. for (int i = 0; i < arr.length; i++)
  9. temp[index[i]]=arr[i];
  10. //copy temp to array
  11. for (int i = 0; i < temp.length; i++) {
  12. arr[i]=temp[i];
  13. index[i]=i;
  14. }
  15.  
  16. }
  17. public static void main(String[] args) {
  18. record();
  19. System.out.println("Recorded array is");
  20. System.out.println(Arrays.toString(arr));
  21. System.out.println("modified index array is");
  22. System.out.println(Arrays.toString(index));
  23. }
  24.  
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement