Home | Ajax | BioInformatics | Dojo | EAI | EJB | Hibernate | J2ME | Java | Java Glossary | Java Servlets | JavaScript | Jboss | JDBC | JDO | Jmeter | JSF | JSP | JUnit | Maven | MySQL | Spring Framework | SQL | Struts | Technology | WAP | Web Services | XML


 
  
 
Programming Tutorials: Ajax | Articles | JSP | Bioinformatics | Database | Free Books | Hibernate | J2EE | J2ME | Java | JavaScript | JDBC | JMS | Linux | MS Technology | PHP | RMI | Web-Services | Servlets | Struts | UML
 

 
Facing Programming Problem?
Ask Questions?, Browse Latest Questions, Question-Answer Guidelines
Java
  JDO Tutorials
  EAI Articles
  Struts Tutorials
  Java Tutorials
  Java Certification
  Java Applet
Questions
Comments

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

                         

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

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

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

Latest Searches:
Button
form action=
encapsulation
java strings
Installing Sun JDK on
real time in java
average numbers
set session servlet
ejp
Get first day of week
notes applet
fireTableCellUpdated
netbeans jsp jdbc
FlowLayout
breakаÐ?????аÐ????а
reading excel file usi
string trim/index.php?
hash map for loop
calculator code usind
Javascript Date and Ti
jsp bank examples
java: read string arra
Photoshop Photo Effect
requestDispatcher
HOWTO: Install Ruby on
combo box my sql
check character
dojo debug
capture screen j2me
how to create war file
struts2 gwt
Flash Special Effects
Create table and inser
struts 1 vs struts 2
bank application
java date compare exam
String to array in jav
Javascript Menus Image
Get Image
actionlistener
Using Select Statement
download file using js
J2ME Gauge
capture image j2me
Photoshop Write messag
flex struts
sum
Tracing in a multithre
validate radio button
Copy One Database Tabl
Access Infotech
drill down using jfree
capture image
Flash Flash tutorials
insert content to text
Photoshop Effects Hole
ready made component o
linked list and window
jQuery To Slide Effect
file input output
WHERE Statement in SQL
convert byte to char
user registration
arithmetic date
width
define
scwcd
saveOrUpdate faces
login using JSP
spring MVC application
prime numbers
how to create session
com.mysql.jdbc.Driver
Bryce 3d Materials Wat
trusted root certifica
finding the square of
insert data to text fi
what is the difference
system.out.println(x
iport
Java String toLowerCase Example
Java String toCharArray Example
Java String substring Example
Java String indexOf Example
Java String startsWith Example
Java String hashCode Example
Java String matches Example
Java String length Example
Java String lastIndexOf Example
Java String isEmpty Example
Java String equalsIgnoreCase Example
Java String equals Example
Java String endsWith Example
Java String copyValueOf Example
Java String contentEquals Example
  EAI Articles
  Java Certification
Tell A Friend
Your Friend Name
Search Tutorials

 

 
 
Browse all Java Tutorials
Java JSP Struts Servlets Hibernate XML
Ajax JDBC EJB MySQL JavaScript JSF
Maven2 Tutorial JEE5 Tutorial Java Threading Tutorial Photoshop Tutorials Linux Technology
Technology Revolutions Eclipse Spring Tutorial Bioinformatics Tutorials Tools SQL
 

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 | 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.