Sorting arrays using java

Sorting a numbers after it entered.

Page 1 of 1

2 Replies - 1427 Views - Last Post: 25 July 2008 - 09:09 AM Rate Topic: -----

#1 jhigz77  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 02-July 08

Sorting arrays using java

Post icon  Posted 24 July 2008 - 06:57 PM


import java.util.*;

public class sorting{		// Unfinish!!!
	
	public static void main(String args[]){
		java.io.BufferedReader in;
		String line="";
		
		int i1=0,i2=0,i3=0,i4=0,i5=0;
		int x=0;
		
		in=new java.io.BufferedReader(new java.io.InputStreamReader(System.in));




{

		System.out.print("\n\n\tNum[01]:");
		  System.out.flush();
		line=in.readLine();
		i1=Integer.valueOf(line).intValue();
 		
 		
 		System.out.print("\n\n\tNum[02]:");
		  System.out.flush();
		line=in.readLine();
		i2=Integer.valueOf(line).intValue();
		 
		System.out.print("\n\n\tNum[03]:");
		  System.out.flush();
		line=in.readLine();
		i3=Integer.valueOf(line).intValue();
		 
		
		System.out.print("\n\n\tNum[04]:");
		  System.out.flush();
		line=in.readLine();
		i4=Integer.valueOf(line).intValue();
		 
		
		System.out.print("\n\n\tNum[05]:");
		  System.out.flush();
		line=in.readLine();
		i5=Integer.valueOf(line).intValue();
		 
		
				
		
		System.out.println("\n\n");
		
	
			System.out.print("\n\n\tEnter Number to sort:");
			  System.out.flush();
			line=in.readLine();
			x=Integer.valueOf(line).intValue();
			
			
			
			for(int i=0; i<x.length; i++){
				
				 System.out.println(i + ": " + x[i]); 

			  
								
				
				Arrays.sort();
				
				
			}
			
			
	}		
	
	
	
	
	
			



Is This A Good Question/Topic? 0
  • +

Replies To: Sorting arrays using java

#2 1lacca  Icon User is offline

  • code.rascal
  • member icon

Reputation: 44
  • View blog
  • Posts: 3,822
  • Joined: 11-August 05

Re: Sorting arrays using java

Posted 25 July 2008 - 01:48 AM

So what is the question?
Was This Post Helpful? 0
  • +
  • -

#3 lordms12  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 30
  • View blog
  • Posts: 339
  • Joined: 16-February 08

Re: Sorting arrays using java

Posted 25 July 2008 - 09:09 AM

x is not even an array!!!!

To sort array Arrays.sort(array);

Check this for more customized sorting.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1