Skip to content

Instantly share code, notes, and snippets.

@peter279k peter279k/JPA05.java
Created May 25, 2017

Embed
What would you like to do?
TQC+ JAVA
public class JPA05 {
public static void main(String[] argv) {
int[] data = {1, 3, 2, 5, 4, 6};
sort(data);
}
public static void sort(int []data) {
for(int i=0;i<data.length-1;i++) {
for(int j=i+1;j<data.length;j++) {
if(data[i] > data[j]) {
int temp = data[i];
data[i] = data[j];
data[j] = temp;
}
}
show(data);
}
}
public static void show(int []data) {
String str = " ";
for(int index=0;index<data.length;index++) {
if(index == data.length-1) {
str += data[index] + "";
} else {
str += data[index] + " ";
}
}
System.out.println(str);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.