Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package stackoverflow;
- import java.util.Random;
- import java.util.Arrays;
- public class StackOverFlow {
- public static void main(String[] args) {
- Random g = new Random();
- int [] number = new int [70];
- System.out.print("Random Numbers:");
- for (int d = 0 ; d<number.length ; d++){
- int RandomG = g.nextInt(150)+1;
- number[d] = RandomG;
- System.out.print(" " +RandomG);
- }
- System.out.print("\nSorted Numbers:"+Arrays.toString(BubbleSortAsceMethod(number)));
- }
- public static int [] BubbleSortAsceMethod(int[] number){
- int temp;
- for(int i = 0 ; i < number.length-1 ; i++){
- for ( int j = 1 ; j < number.length-i ; j++){
- if ( number[j-1] > number[j]){
- temp = number[j-1];
- number[j-1] = number[j];
- number[j] = temp;
- }
- }
- }
- return number;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement