---
title: "冒泡排序"
author: "ldsjdy"
date: "2014-07-18T16:58:13Z"
tags: []
categories: ["企业架构"]
slug: "untitled"
draft: false
lastmod: "2014-07-18T16:58:13Z"
id: 2093775
url: "https://webqq.iteye.com/blog/2093775"
---

```java


 public static void main( String[] args )
    {
        int[] a = new int[]{1,2,5,3,7,9,6};
        for(int i =0 ; i < a.length;i++){
        	System.out.println(Arrays.toString(a));
        	for(int j = 0;j < a.length-i-1;j++){
        		if(a[j] > a[j+1]){
        			int temp = a[j];
        			a[j] = a[j+1];
        			a[j+1]=temp;
        		}
        	}
        }
     
    }

```



```java

[1, 2, 5, 3, 7, 9, 6]
[1, 2, 3, 5, 7, 6, 9]
[1, 2, 3, 5, 6, 7, 9]
[1, 2, 3, 5, 6, 7, 9]
[1, 2, 3, 5, 6, 7, 9]
[1, 2, 3, 5, 6, 7, 9]
[1, 2, 3, 5, 6, 7, 9]


```