SHARE
TWEET

Untitled

a guest Feb 26th, 2020 91 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // =============================================
  2. // Shawn McAllister
  3. // Week 5 Debug
  4. // 3 bugs
  5. // =============================================
  6.  
  7.  
  8. import javax.swing.JOptionPane;
  9. import java.util.Array;
  10.  
  11. public class week5DebugBroken {
  12.     private static int arrSort(int[] arr){
  13.         int temp;
  14.  
  15.         for(int i = 0; i < arr.length - 1; i++){
  16.             for(int j = 0; j < arr.length - 1; j++){
  17.                 if(arr[j] > arr[j + 1]){
  18.                     temp = arr[j];
  19.                     arr[j] = arr[j + 1];
  20.                     arr[j + 1] = temp;
  21.                 }
  22.             }
  23.         }
  24.  
  25.         return arr;
  26.     }
  27.  
  28.     public static void main(String[] args){
  29.         int arr[] = { 22, 15, 10, 55, 5, 23};
  30.  
  31.         arrSort(arr);
  32.  
  33.         JOptionPane.showMessageDialog(null, Array.toString(arr));
  34.     }
  35. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top