26332 total geeks with 3498 solutions
Recent challengers:
  • krc bonus 5 - 12:32PM
  • krc bonus 23 - 11:03AM
  • krc bonus 12 - 08:08AM
 Welcome, you are an anonymous user! [register] [login] Get a yourname@osix.net email address 

Articles

GEEK

User's box
Username:
Password:

Forgot password?
New account

Shoutbox
MaxMouse
It's Friday... That's good enough for me!
CodeX
non stop lolz here but thats soon to end thanks to uni, surely the rest of the world is going good?
stabat
how things are going guys? Here... boring...
CodeX
I must be going wrong on the password lengths then, as long as it was done on ECB
MaxMouse
lol... the key is in hex (MD5: of the string "doit" without the "'s) and is in lower case. Maybe i should have submitted this as a challenge!

Donate
Donate and help us fund new challenges
Donate!
Due Date: Jun 30
June Goal: $40.00
Gross: $0.00
Net Balance: $0.00
Left to go: $40.00
Contributors


News Feeds
The Register
Julian Assange: I"m
quite happy to
sleep on Ecuador"s
sofa FOREVER
Supercomputer sage
Cray musters Lustre
cluster storage
hustler
Sneaky Seagate
slips "world"s
fastest" enterprise
disk mutant into
the wild
Hey mobile firms:
About that Android
thing... Did Google
add a lockout
clause?
PC makers REALLY
need Windows 8.1 to
walk on water - but
guess what?
Norks taunt, yank
Yanks" crank over
PRISM: US is
"rights abuse
kingpin"
Washout 2012
summer, melty
Greenland "nothing
to do with Arctic
ice or warm oceans"
Exagrid hires
former IBM exec,
Hitachi bod to help
flog disk grid tech
Out with a bang:
The Last of Us lets
PS3 exit with head
held high
EU Justice
Department stalls
India"s security
clearance
Slashdot
Google"s Crazy Lack
of Focus: Is It
Really Serious
About Enterprise?
Cat-like Robot Runs
Like the Wind
Revisiting Amdahl"s
Law
Altering Text In
eBooks To Track
Pirates
NVIDIA To License
Its GPU Tech
MySQL Man Pages
Silently Relicensed
Away From GPL
Verizon Accused of
Intentionally
Slowing Netflix
Video Streaming
Oculus Rift Raises
Another $16 Million
KWin Maintainer:
Fanboys and Trolls
Are the Cancer
Killing Free
Software
Google Files First
Amendment Challenge
Against FISA Gag
Order
Article viewer

Introduction to Arrays, and Sorting using Java



Written by:dimport
Published by:SAJChurchey
Published on:2003-06-21 07:19:46
Topic:Java
Search OSI about Java.More articles by dimport.
 viewed 10906 times send this article printer friendly

Digg this!
    Rate this article :
Seems you guys want more tutorials; well here is a simple explanation of Arrays, and how to sort them in one of our more popular languages, Java.

We all recognize variables as places to store data in our programs/applications, but this can become an arduous task, and in many cases the variables are of the same type. But what can we do about it you’re thinking! Well we can use Arrays. Generally speaking an array is a group of similar variable types. Let’s take an example, I have 5 dogs, and I want to write a program to keep track of them. Now since I am lazy, I am not going to give them all a separate variable, but instead use an array; which looks like this: -
String[] myDogs;
Or I could even write: -
String myDogs[];
Flexible eh? The square brackets denote an array, and the string defines their type, and myDogs is the variable name. The above example creates the array, but we can’t actually store any information in there, because we haven’t told the computer to do so! So let’s do it: -
String[] myDogs = { “Aton”, “barnseyboy”, “shn”, “gabbana”, “Rob”};
Not so hard eh? Aton is a good dog who always fetches me the paper, barnseyboy is a poodle; shn and Rob are very lazy; and gabbana spends his time chasing all the lady dogs around the neighborhood.
So we’ve created our array, but how do we access it? I had a feeling you would ask that so let’s say we want to sort the array alphabetically, and print it them out. I would use the following code: -
Int j = 0;
For (j < myDogs.length; j++)
Arrays.sort(myDogs);
System.out.println(“Dog number” + j + “is” + myDogs[j - 1]);
Remember, while using this code; because we are using the .length and .sort methods to import all of the java utils. So to do this just put import java.util.*; at the top of the class.
Not too hard? If you have any questions just pop over to the forums, I’m sure someone will be able to help.

This article was originally written by sliptop

Did you like this article? There are hundreds more.

Comments:
Anonymous
2008-09-25 08:08:50
wap to sort nos.(bubble) .stops the operation when the counter for sorting index is 100,1000 and so on. stores the contents of registers, prog. counter and partially sorted list of data and resumes the operation after 30 seconds
lifeone
2010-01-15 16:51:14
www.bagsshow.com
Anonymous
2011-05-30 05:48:37
http://www.coach-replicas.com/
Anonymously add a comment: (or register here)
(registration is really fast and we send you no spam)
BB Code is enabled.
Captcha Number:


Blogs: (People who have posted blogs on this subject..)
goldie
using javamail i am getting excetion like this on Tue 5th May 6am
avax.mail.MessagingException: Unknown SMTP host: pop3.gmail.com; nested exception is: java.net.UnknownHostException: pop3.gmail.com at com.sun.mail.smtp.SMTPTransport.openServ er(SMTPTransport.java:1543) at com.sun.mail.smtp.SMTPTransport.protocol
kdemetter
Blog entry for Wed 11th Apr 1pm on Wed 11th Apr 1pm
lately i've been playing with Java a little . I'm working on a application that can create a list of meals for one week from a large list of meals . well , it works . just some problems with Swing not doing what i want it to do :-) http://www.os

Test Yourself: (why not try testing your skill on this subject? Clicking the link will start the test.)
Java tricks by berry120

Think you really know Java? This won't test you on elaborate and never heard of APIs. It will test you on stuff that isn't always as it seems...
Java Programming - Level 1 by D-Cypell

A first level Java programming test. The test contains 10 questions on Java syntax, concepts and the API.
History and Basic Programming Knowledge by HackMaster321

A test of your knowledge of java history and programming. Tests your ability to recall java historical facts, and remember what some of javas more common commands and syntax are and do.


     
Your Ad Here
 
Copyright Open Source Institute, 2006