Answer to Question #309539 in Java | JSP | JSF for Kyle

Question #309539

Write a Java program to arrange the elements of a given array of integers where all negative integers appear before all the positive integers.


1
Expert's answer
2022-03-13T09:35:34-0400
int [] nums = new int[]{3, -2, 1, 2, 3, -6, 9, -8, -5};
for (int i = 0; i < nums.length; i++){
    if(nums[i] < 0) {
        System.out.print(nums[i] + " ");
    }
}
for (int i = 0; i < nums.length; i++){
    if(nums[i] > 0) {
        System.out.print(nums[i] + " ");
    }
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS