Core Java| JSP| Servlets| XML| EJB| JEE5| Web Services| J2ME| Glossary| Questions?

 

 

 

 

 

 

 

 

 

 

 

 

 

Search Tutorials:
 

Software Solutions and Services
 

 
  JDO Tutorials
  EAI Articles
  Struts Tutorials
  Java Tutorials
  Java Certification
  Java Applet
Questions
Comments
 
Java - Array in Java 
 

Array is the most important thing in any programming language.

 

Array Example - Array in Java

                         

Array: Array is the most important thing in any programming language. By definition, array is the static memory allocation. It allocates the memory for the same data type in sequence. It contains multiple values of same types. It also store the values in memory at the fixed size. Multiple types of arrays are used in any programming language such as: one - dimensional, two - dimensional or can say multi - dimensional. 

Declaration of an array:  
int num[]; or int num = new int[2];
Some times user declares an array and it's size simultaneously. You may or may not be define the size in the declaration time. such as:
int num[] = {50,20,45,82,25,63}; 

In this program we will see how to declare and implementation. This program illustrates that the array working way. This program takes the numbers present in the num[] array in unordered list and prints numbers in ascending order. In this program the sort() function of the java.util.*; package is using to sort all the numbers present in the num[] array. The Arrays.sort() automatically sorts the list of number in ascending order by default. This function held the argument which is the array name num.

Here is the code of the program:-

import java.util.*;

public class  array{
 
 public static void main(String[] args){
    int num[] = {50,20,45,82,25,63};
    int l = num.length;
    int i,j,t;
    System.out.print("Given number : ");
    for (i = 0;i < l;i++ ){
      System.out.print("  " + num[i]);
    }
    System.out.println(
"\n");
    System.out.print("Accending order number : ");
    Arrays.sort(num);
  
  for(i = 0;i < l;i++){
      System.out.print("  " + num[i]);
    }
  }
}

Output of the program:

C:\chandan>javac array.java

C:\chandan>java array
Given number : 50 20 45 82 25 63

Ascending order number : 20 25 45 50 63 82

      

                         

» View all related tutorials
Related Tags: c file array class list ui lists method get name using this oo root example where to exam drive store

Leave your comment:

Name:

Email:

URL:

Title:

Comments:


Enter Code:

Audio Version
Reload Image
 

Note: Emails will not be visible or used in any way, and are not required. Please keep comments relevant. Any content deemed inappropriate or offensive may be edited and/or deleted.

No HTML code is allowed. Line breaks will be converted automatically. URLs will be auto-linked. Please use BBCode to format your text.

Add This Tutorial To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 

Current Comments

10 comments so far (
post your own) View All Comments Latest 10 Comments:

tnx guys, its really comprehensive,, it help me a lot.....
i hope you could email me some codes for animated applets..

i dont know what is it called but,,,,its like an japplet where in you can manipulate the movements of the objects,..

tnx.

Posted by thereece on Friday, 01.30.09 @ 02:41am | #84310

To
this web site is very benificial web site .i m satisfy provide by basic concept of so i wants to your thanks and i hope that you will be provid this type knowledge in future time.
1.my topic is Java Virul Machine so plz do understand to me.
2. java fully object oriented language why?
3.java does not supports many things such as:-pointer,operator overloading why?
so plz solve my problem.
your's faith fully Mragendra Pratap Singh

Posted by Mragendra Pratap Singh on Sunday, 12.7.08 @ 10:14am | #82483

Please send me java programing source code at "akvy@ymail.com".
Thanking you...

Posted by Abdul on Thursday, 09.25.08 @ 08:39am | #80682

it is so easy to understand that program i really so happy to see this type of program in ur website it should be continued forever

Posted by V.Loganayaki on Thursday, 09.4.08 @ 07:48am | #77064

what is an array in javA?

Posted by lescil on Tuesday, 08.19.08 @ 11:15am | #73712

ill pay about 50$ for anyone to write me a tictactoe program by this saturday contact my
e-mail chaos2238@hotmail.com

Posted by Evans on Thursday, 05.15.08 @ 06:14am | #59984

I am in a Java class and I need to see step by step instructions on how to do it.

Bill

Posted by William Markavich on Friday, 03.21.08 @ 04:46am | #53535

Check this out:

public boolean isSorted(int[] a) {
boolean sort = false;
for(int i = 0; i < a.length-1; i++) {
if(a[i] < a[i+1]) sort = true;
else {sort = false; break;}
}
return sort;
}

Posted by Nick T on Thursday, 03.6.08 @ 05:47am | #51629

very well example for beginners

Posted by mukesh ranjan shrivastava on Tuesday, 10.16.07 @ 17:56pm | #34212

nice tutorial

Posted by Deepakpuspita on Monday, 11.27.06 @ 15:19pm | #138

Training Courses
Tell A Friend
Your Friend Name
Website Designing Services
 
Web Designing Packages From $150!
 
Website Designing Company Web Hosting
 
Website Designing Quotation
 
Search Tutorials:

 

 
 

Home | JSP | EJB | JDBC | Java Servlets | WAP  | Free JSP Hosting  | Search Engine | News Archive | Jboss 3.0 tutorial | Free Linux CD's | Forum | Blogs

About Us | Advertising On RoseIndia.net  | Site Map

India News

Indian Software Development Company | iPhone Development Company in India | Flex Development Company in India | Java Training Delhi | Java Training at Noida |

Send your comments, Suggestions or Queries regarding this site at roseindia_net@yahoo.com.

Copyright © 2008. All rights reserved.