A two-dimensional array, a set of rectangular arrays

Source: Internet
Author: User

A two-dimensional array, a set of rectangular arrays

two-dimensional array, rectangular array Collection

a . Two-dimensional arrays:

One-dimensional array---beans

Two-dimensional array---table

1) Definition:

One-dimensional arrays:

data type [] array variable name = new data type [array length];

data type [] array variable name = new data type [array length]{1,2,3 ...};

2) Two-dimensional array:

data type [,] array variable name = new data type [number of rows, number of columns];

int[,] a = new int[3,4];

Assignment value:

a[row subscript, column subscript] = value subscript is starting from 0

Value:

a[row subscript, column subscript]

two . jagged data, an array of arrays.

Defined:

First step: Define a large Array

data type [] A = new data type [number of rows] [];

Step two: Define the decimal group

Data type [] a1 = new data type [number of columns];

Data type [] a2 = new data type [number of columns];

......

Step three: Put the decimal group in a large array

A[0] = A1;

A[1] = A2;

three . Collection

1 , ArrayList linked list, no length limit, can add or remove elements at any time .

Need to be preceded by: using System.Collections;

Defined:

ArrayList a = new ArrayList ();

Operation:

A.add (data): add

A.insert (index number, data): Insert

A.removeat (index number): delete

A.count the number of elements in the collection

Value:

a[Subscript]

The values taken out need to be cast

2 , list< type > linked list, with no length limit, can add or remove elements at any time. Only data of the specified type can be placed, and no casts are taken out.

Defined

list< type > variable name = new list< type > ();

List<int> a = new list<int> ();

Operation:

A.add (data): add

A.insert (index number, data): Insert

A.removeat (index number): delete

A.count the elements in a collection.

A two-dimensional array, a set of rectangular arrays

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.