Help ! Java question

I see mostly questions pertaining to mostly front end work. Can you guys help me with a Java question?

Having trouble learning this. I am trying to create an array. The program needs to take in the user data and then sort them. I do not want to use arrays.sort; Can someone help me? My code is listed below. Also, is ther

import java.util.Scanner;

public class Sorter 
{
	public static void main(String[]args)
	{
		Scanner sc = new Scanner(System.in);
		System.out.print("Enter desired numbers");
	
		int[] spaceship = {0,0,0};
		int[] sortedSpaceship = {0,0,0};
		int i = 0;
		int copy = 0;
		
		
		while (i < 3)
		{
			spaceship[i] = sc.nextInt(); 
			i++;
		}
		
		i = 0;
		while ( i < spaceship.length )
		{	
			System.out.println(spaceship[i]);
						
			if ( i == 0)
			{
				sortedSpaceship[i] = spaceship[i]; 
			}
			else
			{
				 
			}		
			
			if ( spaceship[i] < sortedSpaceship[i]) 
			{
			}			
//			copy = spaceship[i];
//			
//			spaceship[i] = spaceship[i+1];
//			
//			spaceship[i + 1] = copy;
			
			i++;
		}
	}
}

I cleaned up your code.
You need to use triple backticks to post code to the forum.
See this post for details.

Thank you for the information.

@JesseSmith3rd Sorry, it’s been way too long since I touched Java. However, a quick Google search for “bubble sort” returned the following. Hope these help towards a solution.

Bubble Sort
http://mathbits.com/MathBits/Java/arrays/Bubble.htm

Java: Bubble Sort Algorithm [Ascending Order]
http://crunchify.com/java-bubble-sort-algorithm-ascending-order-sample/

1 Like

Thank you James. Really appreciate it.