TechArena Community

TechArena Community (
-   Software Development (
-   -   Object oriented programming with java (

cloud101 20-02-2012 11:15 AM

Object oriented programming with java
Can someone please tell me what an array is, and what are the advantages of using arrays? Also please type a few lines of code demonstrating how you would declare an array and initialize it.

Please help.

Brunon 20-02-2012 03:47 PM

Re: Object oriented programming with java
Array is mainly significant thing in any programming language. Array is a fixed memory allocation and this will assign the memory for same data type sequence. Array contains multiple values of same types and this all values are set memory at same size. Multiple type of array used in all programming language such as one - dimensional, two - dimensional or can say multi - dimensional.
Declaration of an array:
int new[]; or int new= new int[2]; or int num[] = {5,2,4,8,7,6};

Here is the code of the program:


import java.util.*;
public class  array{
  public static void main(String[] args){
  int new[] = {50,20,45,82,25,63};
  int a = new.length;
  int w,b,y;
  System.out.print("Given number : ");
  for (w = 0;w < a;w++ ){
  System.out.print("  " + num[w]);
  System.out.print("Accending order number : ");
    for(w = 0;w < a;w++){
  System.out.print("  " + num[w]);

cloud101 22-02-2012 01:11 AM

Re: Object oriented programming with java
Thank you so much for your great explanation.

All times are GMT +5.5. The time now is 06:08 AM.