Advertisement
aneliyanestorova

ArraySort

Apr 11th, 2019
429
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1. import java.util.*;
  2. public class ArraySort {
  3. public static void main(String[]args){
  4. Scanner scanner = new Scanner(System.in);
  5. String num = scanner.nextLine();
  6. String[] numbers = num.split(",");
  7.  
  8. List<String> input = Arrays.asList(numbers);
  9.  
  10. List<String>zero =new ArrayList<>();
  11. List<String>positive =new ArrayList<>();
  12. for (String n:input
  13. ) {
  14. int current = Integer.parseInt(n);
  15. if(current>0){
  16. positive.add(n);
  17. }else if(current==0){
  18. zero.add(n);
  19. }
  20. }
  21. positive.addAll(zero);
  22.  
  23. System.out.println(String.join(",",positive));
  24. }
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement