Java #13: How to Sort an Array Automatically

How to sort an array in java

Here’s the full source code of a program I created to print out an array before it is sorted and array after I hit it with the sort function.


* @author Akin

//array imports
import java.util.Arrays;

public class DagbaComputerSamples

* @param args the command line arguments
public static void main(String[] args)

//dagbaArray Creation
int dagbaArray[] = {5,25,10, 3000,8};

//printing the Array before Sort
for (int number: dagbaArray)
System.out.println(“Original Array Member: ” +number);//print
}//end of non sorted dagbaArrays Array

//print break(for readability)

//now sorting the array

for (int number: dagbaArray)//sorted list looop
System.out.println(“Sorted array number: “+number);//printing out sorted array
}//end of printing newly sorted list
}//End of Main
}//end of Class

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s