Java Array Formatting

Okay so I am learning bubble sorting in my java class right now and I have it down pretty much but I cant find an effective way to format the inside of the array list to one decimal place. Look at code for example.

import java.util.Arrays;

import java.util.Random;

public class BubbleSortTest {

public static void sort(double arr[]){

int arrayLength = arr.length;

for (int i = 0; i < arrayLength-1; i++)

for (int j = 0; j < arrayLength-i-1; j++)

if (arr[j] > arr[j+1])

{

//swap temp and arr[i]

double temp = arr[j];

arr[j] = arr[j+1];

arr[j+1] = temp;

}

}

/* Prints the array */

public static...

Read More »

By: StackOverFlow - Wednesday, 7 November

Related Posts