fork(2) download
  1. import java.util.*;
  2. import java.lang.*;
  3.  
  4. class Main
  5. {
  6. public static void main (String[] args) throws java.lang.Exception
  7. {
  8. byte[] input = {77, 83, 65, 80, 79, 67, 32, 32, 32, 32, 32, 32, 32};
  9. int i = input.length;
  10. while (i-- > 0 && input[i] == 32) {}
  11.  
  12. byte[] output = new byte[i+1];
  13. System.arraycopy(input, 0, output, 0, i+1);
  14.  
  15. System.out.println(Arrays.toString(input));
  16. System.out.println(Arrays.toString(output));
  17. }
  18. }
Success #stdin #stdout 0.05s 213440KB
stdin
Standard input is empty
stdout
[77, 83, 65, 80, 79, 67, 32, 32, 32, 32, 32, 32, 32]
[77, 83, 65, 80, 79, 67]