Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and medical aesthetics - How to convert a list collection into a string array?
How to convert a list collection into a string array?
The method of converting a list collection into a string array is as follows:

Enter code:

[java] View Plain Text

List & lt string & gtlist = new ArrayList & lt string & gt ();

list . add(" a 1 ");

list . add(" a2 ");

String[]toBeStored = list . to array(new String[list . size()]);

for(String s : toBeStored) {

system . out . println(s);

}

Character array refers to an array used to store character data. The general form of its definition is: char array name [data length]. Character array is used to store characters or strings, and one element in the character array stores one character, occupying one byte of memory. C language has no string type, and strings are stored in character arrays.

An array used to store character data is called a character array. An element in a character array holds a character. The method of defining a character array is similar to that of defining a numeric array.

The general form of its definition is: char array name [data length]

For example:

char c[ 10];

c[0]= ' I '; c[ 1]=“”; c[2]= ' l '; c[3]= ' o '; c[4]= ' v '; c[5]= ' e '; c[6]=“”; c[7]= ' y '; c[8]= ' o '; c[9]= ' u ';

C is defined as a character array containing 10 elements.

Because character data is stored in the form of integers (ASCII codes), you can also use integer arrays to store character data, for example:

int c[ 10];

But at this time, each array element occupies 2 bytes of storage unit, wasting storage space. [ 1]?

Character arrays can also be two-dimensional or multi-dimensional arrays, for example:

char c[5][ 10];

This is a two-dimensional character array.