I have an annoying problem with the array I made
When I run the program it does not print nicely and on different lines. Its just one long line. When I add "+ " " " to the println it puts a space between every number in the array which is bothering me.
where did I go wrong?
import java.util.Arrays;
import java.util.Scanner;public class Sorter {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
System.out.println("Input array size");
int arraySize = input.nextInt();
int originalArray[] = new int[arraySize];
for (int i = 0; i < originalArray.length; i++){
originalArray = (int)(Math.random() * 101);
System.out.print(originalArray); //print#1
System.out.println();
}int selectionSortedArray[] = new int[arraySize];
for (int j = 0; j < selectionSortedArray.length; j++){
selectionSortedArray[j] = (int)(Math.random() *101);
performSelectionSort(selectionSortedArray);
System.out.print(selectionSortedArray[j]); // print number 2
System.out.println();
}
int utilSortedArray[] = new int[arraySize];
for (int s = 0; s < utilSortedArray.length; s++){
utilSortedArray= (int)(Math.random() * 101);); // print #3
Arrays.sort(utilSortedArray);
Arrays.equals(selectionSortedArray, utilSortedArray);
System.out.print(utilSortedArray
System.out.println();
}}
public static void performSelectionSort(int[] a) {
int i, j;
int minIndex = 0;
int minValue;
int temp;
for (i = 0; i < a.length; i++) {
minValue = a_;
minIndex = i;
for (j = i; j < a.length; j++) {if (a[j] < minValue) {
minValue = a[j];
minIndex = j;
}
}temp =a_;
a_=a[minIndex];
a[minIndex] = temp;}
}}_~~~~