September 03, 2010, 10:30:34 AM *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
  Home Help Media Affiliates Login Register  
Pages: [1]   Go Down
  Print  
Author Topic: Sorting a String or int array using Arrays.sort()  (Read 1317 times)
0 Members and 1 Guest are viewing this topic.
Arkie
Javaforums.net Admin
Senior Member
*

Reputation: 16
Developer @ Javaforums.net
Offline Offline
Posts: 2620
Referrals: 13

WWW Awards
« on: February 05, 2009, 03:47:45 PM »

Code
GeSHi (java):
  1. import java.util.Arrays;
  2.  
  3. public class ArraySorter {
  4. public static void main(String[] args){
  5. String[] s = {"d", "a" ,"c", "b"};
  6. int[] i = {4,1,3,2};
  7. Arrays.sort(s); Arrays.sort(i);
  8. System.out.println("Sorted String: " + Arrays.toString(s));
  9. System.out.println("Sorted int: " + Arrays.toString(i));
  10. }
  11. }
  12.  
Created by GeSHI 1.0.7.20

output
Sorted String:   [a, b, c, d]
Sorted int:   [1, 2, 3, 4]

Logged

Java and .NET developer

To students: It doesn't matter how hard you've studied; the material won't be on the exam anyway.

Fan of http://www.retardedweblogger.com
Oh man, too much stuff to do in so little time.

http://img222.imageshack....707/arkietomatoesmall.jpg
Blizzcon 2k9 Grubby and Cassandra Ng engaged ! <3
Triple D, eerste Denken Dan Doen
Javaforums.net/forum :: A friendly community for software developers and students that want to learn Java!
« on: February 05, 2009, 03:47:45 PM »

 Logged
jurka
Staff
Member
*
*

Reputation: 5
Offline Offline
Posts: 188
Referrals: 0

Awards
« Reply #1 on: February 05, 2009, 04:43:28 PM »

Yeah with Arrays class you can do many things getting array as list, sorting, comparing and searching. Great library so you don't have to waist your time to reinvent wheel.
Logged
Javaforums.net/forum :: A friendly community for software developers and students that want to learn Java!
   

 Logged
Pages: [1]   Go Up
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.10 | SMF © 2006-2009, Simple Machines LLC
TinyPortal v0.9.8 © Bloc
Valid XHTML 1.0! Valid CSS!
Page created in 0.227 seconds with 34 queries.

Google visited last this page August 31, 2010, 05:08:04 AM