How to define an Array : Array Basics « Collections « Java Tutorial

Home
Java Tutorial
1.Language
2.Data Type
3.Operators
4.Statement Control
5.Class Definition
6.Development
7.Reflection
8.Regular Expressions
9.Collections
10.Thread
11.File
12.Generics
13.I18N
14.Swing
15.Swing Event
16.2D Graphics
17.SWT
18.SWT 2D Graphics
19.Network
20.Database
21.Hibernate
22.JPA
23.JSP
24.JSTL
25.Servlet
26.Web Services SOA
27.EJB3
28.Spring
29.PDF
30.Email
31.J2ME
32.J2EE Application
33.XML
34.Design Pattern
35.Log
36.Security
37.Apache Common
38.Ant
39.JUnit
Java Tutorial » Collections » Array Basics 




  1. An array is a named set of same-type variables.
  2. Each variable in the array is called an array element.
  3. The first element will have an index of 0.
public class MainClass {

  public static void main(String[] arg) {
    int[] intArray = new int[10];

    for (int i = 0; i < 10; i++) {
      intArray[i100;
    }

    for (int i = 0; i < 10; i++) {
      System.out.println(intArray[i]);
    }

  }

}
100
100
100
100
100
100
100
100
100
100














9.3.Array Basics
9.3.1.How to define an Array
9.3.2.Initializing array elements by index
9.3.3.Alternative Array Declaration Syntax
9.3.4.Anonymous arrays are declared similarly to regular arrays
9.3.5.An array is a Java object
9.3.6.To reference the components of an array
9.3.7.The Length of an Array
9.3.8.Initializing Arrays
9.3.9.Using a for loop to iterate over all the elements and set the values
9.3.10.Arrays of Characters
9.3.11.Using the Collection-Based for Loop with an Array
9.3.12.Changing Array Size
9.3.13.Array Reallocation
9.3.14.Use System.arraycopy to duplicate array
9.3.15.Minimum and maximum number in array
9.3.16.Shuffle elements of an array
9.3.17.Merge (or add) two arrays into one
9.3.18.Circular Buffer
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.