> For the complete documentation index, see [llms.txt](https://boxlang.ortusbooks.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/array/arraynew.md).

# ArrayNew

Create a new array.

## Method Signature

```
ArrayNew(dimensions=[integer], isSynchronized=[boolean])
```

### Arguments

| Argument         | Type      | Required | Description                                                               | Default |
| ---------------- | --------- | -------- | ------------------------------------------------------------------------- | ------- |
| `dimensions`     | `integer` | `false`  | The dimension of the array to create (currently only 1 is supported).     | `1`     |
| `isSynchronized` | `boolean` | `false`  | Whether the array should be thread-safe (synchronized). Default is false. | `true`  |

## Examples

### Create the One dimensional array

Uses the arrayNew function to create the new array

[Run Example](https://try.boxlang.io/?code=eJx1jkELgkAUhM%2Furxg8KQhieRMDOwR1qIP9gYVesbSt8txlsei%2Ft4rRqcvM4c18bwz5hlmOqCEnP5JPUCCtxNA9aDmJPMeZpRl6pYnhO75L7py54NoxtvsdmKxjAzv2JJIkoG5FNulq1vWsJVLUG7xENH9qyf4PViL6ItlRJd5pArNMzRAqZYa40RpqgCet46niWVk6Odu7QD60p2NLrKRWT%2FqVw4aQ%2FACv%2B0zp)

```java
newArray = arrayNew( 1 );
someArray =
// Transpiler workaround for BIF return type
(( arg1, arg2, arg3, arg4 ) => {
	arraySet( arg1, arg2, arg3, arg4 );
	return true;
})( newArray, 1, 4, "All is well" );
writeOutput( JSONSerialize( newArray ) );

```

Result: \["All is well", "All is well", "All is well", "All is well"]

### Create the Two dimensional array

Uses the arrayNew function to create the new array

[Run Example](https://try.boxlang.io/?code=eJzLSy13LCpKrFSwVUgE0X6p5RoKRgqa1lx5UJloBUOFWDABVKPklllUXKJQlphTmqpElhoj%2FGqMkMwJTk3Oz0vBpcgIq6LyosySVP%2FSkoLSEg0Fr2B%2Fv%2BDUoszEnMyqVA0FmAEKmiD%2FAQDN5k2Q)

```java
newArray = arrayNew( 2 );
newArray[ 1 ][ 1 ] = "First value";
newArray[ 1 ][ 1 ] = "First value";
newArray[ 1 ][ 2 ] = "First value";
newArray[ 2 ][ 1 ] = "Second value";
newArray[ 2 ][ 2 ] = "Second value";
writeOutput( JSONSerialize( newArray ) );

```

Result: \[\["First value", "First value"],\["Second value", "Second value"]]

### Create unsynchronized array

Uses the arrayNew function to create the new unsynchronized array

[Run Example](https://try.boxlang.io/?code=eJzLSy13LCpKrFSwVUgE0X6p5RoKhjoKaYk5xakKmtZceVAFeokFBal5KRoKSvl5qUogmfKizJJU%2F9KSgtISDQWvYH%2B%2F4NSizMSczKpUDQWYLgVNkEoAs4AhBw%3D%3D)

```java
newArray = arrayNew( 1, false );
newArray.append( "one" );
writeOutput( JSONSerialize( newArray ) );

```

Result: \["one"]

### Create an array using implicit notation

Instead of using arrayNew you can also create an array using square brackets.

[Run Example](https://try.boxlang.io/?code=eJzLSy13LCpKrFSwVYhW4OJUys9LVdIB0iXl%2BUpcsdZc5UWZJan%2BpSUFpSUaCl7B%2Fn7BqUWZiTmZVakaCnkwvZoKmtZcAEruFrI%3D)

```java
newArray = [ 
	"one",
	"two"
];
writeOutput( JSONSerialize( newArray ) );

```

Result: \["one", "two"]

### Create an array with data type

When using data types on array creation, items are converted if possible, otherwise an error is thrown.

```java
typedArray = arrayNew[ "boolean" ]( 1 );
typedArray[ 1 ] = true;
typedArray[ 2 ] = "true";
typedArray[ 3 ] = 1;
typedArray[ 4 ] = "1";
typedArray[ 5 ] = "yes";
typelessArray = arrayNew( 1 );
typelessArray[ 1 ] = true;
typelessArray[ 2 ] = "true";
typelessArray[ 3 ] = 1;
typelessArray[ 4 ] = "1";
typelessArray[ 5 ] = "yes";
writeOutput( JSONSerialize( [
	typedArray,
	typelessArray
] ) );

```

Result: \[\[true,true,true,true,null,true],\[true,"true",1,"1",null,"yes"]]

### Additional Examples

[Run Example](https://try.boxlang.io/?code=eJxLVLBVSCwqSqz0Sy3XUDBU0LTm0tdX8MwtyMlMziyBSCnk5ZcklmTm53El6iUWFKTmpWgoRMdClZZnlmQolCXmlKYWI0tzcSolKukAySQQaQzEJkAcHQskqrk4OZ39fQN8XCMUrBRKikpTuThrgeKFpalFEGcoZabopCSWpCopaHKB7UkpzS3QUEgEMQGlfTAO)

```java
a = arrayNew( 1 );
// Implicit array notation
a.append( [] );
// with values
a.append( [
	"a",
	"b",
	3,
	4,
	[],
	{
		COMPLEX : true
	},
	queryNew( "id,date" )
] );
dump( a );

```

## Related

* [ArrayAppend](/boxlang-language/reference/built-in-functions/array/arrayappend.md)
* [ArrayAvg](/boxlang-language/reference/built-in-functions/array/arrayavg.md)
* [ArrayChunk](/boxlang-language/reference/built-in-functions/array/arraychunk.md)
* [ArrayClear](/boxlang-language/reference/built-in-functions/array/arrayclear.md)
* [ArrayContains](/boxlang-language/reference/built-in-functions/array/arraycontains.md)
* [ArrayContainsNoCase](/boxlang-language/reference/built-in-functions/array/arraycontainsnocase.md)
* [ArrayDelete](/boxlang-language/reference/built-in-functions/array/arraydelete.md)
* [ArrayDeleteAt](/boxlang-language/reference/built-in-functions/array/arraydeleteat.md)
* [ArrayDeleteNoCase](/boxlang-language/reference/built-in-functions/array/arraydeletenocase.md)
* [ArrayEach](/boxlang-language/reference/built-in-functions/array/arrayeach.md)
* [ArrayEvery](/boxlang-language/reference/built-in-functions/array/arrayevery.md)
* [ArrayFilter](/boxlang-language/reference/built-in-functions/array/arrayfilter.md)
* [ArrayFind](/boxlang-language/reference/built-in-functions/array/arrayfind.md)
* [ArrayFindAll](/boxlang-language/reference/built-in-functions/array/arrayfindall.md)
* [ArrayFindAllNoCase](/boxlang-language/reference/built-in-functions/array/arrayfindallnocase.md)
* [ArrayFindFirst](/boxlang-language/reference/built-in-functions/array/arrayfindfirst.md)
* [ArrayFindNoCase](/boxlang-language/reference/built-in-functions/array/arrayfindnocase.md)
* [ArrayFirst](/boxlang-language/reference/built-in-functions/array/arrayfirst.md)
* [ArrayFlatMap](/boxlang-language/reference/built-in-functions/array/arrayflatmap.md)
* [ArrayFlatten](/boxlang-language/reference/built-in-functions/array/arrayflatten.md)
* [ArrayGetMetadata](/boxlang-language/reference/built-in-functions/array/arraygetmetadata.md)
* [ArrayGroupBy](/boxlang-language/reference/built-in-functions/array/arraygroupby.md)
* [ArrayIndexExists](/boxlang-language/reference/built-in-functions/array/arrayindexexists.md)
* [ArrayInsertAt](/boxlang-language/reference/built-in-functions/array/arrayinsertat.md)
* [ArrayIsDefined](/boxlang-language/reference/built-in-functions/array/arrayisdefined.md)
* [ArrayLast](/boxlang-language/reference/built-in-functions/array/arraylast.md)
* [ArrayMap](/boxlang-language/reference/built-in-functions/array/arraymap.md)
* [ArrayMax](/boxlang-language/reference/built-in-functions/array/arraymax.md)
* [ArrayMedian](/boxlang-language/reference/built-in-functions/array/arraymedian.md)
* [ArrayMerge](/boxlang-language/reference/built-in-functions/array/arraymerge.md)
* [ArrayMid](/boxlang-language/reference/built-in-functions/array/arraymid.md)
* [ArrayMin](/boxlang-language/reference/built-in-functions/array/arraymin.md)
* [ArrayNone](/boxlang-language/reference/built-in-functions/array/arraynone.md)
* [ArrayPop](/boxlang-language/reference/built-in-functions/array/arraypop.md)
* [ArrayPrepend](/boxlang-language/reference/built-in-functions/array/arrayprepend.md)
* [ArrayPush](/boxlang-language/reference/built-in-functions/array/arraypush.md)
* [ArrayRange](/boxlang-language/reference/built-in-functions/array/arrayrange.md)
* [ArrayReduce](/boxlang-language/reference/built-in-functions/array/arrayreduce.md)
* [ArrayReduceRight](/boxlang-language/reference/built-in-functions/array/arrayreduceright.md)
* [ArrayReject](/boxlang-language/reference/built-in-functions/array/arrayreject.md)
* [ArrayResize](/boxlang-language/reference/built-in-functions/array/arrayresize.md)
* [ArrayReverse](/boxlang-language/reference/built-in-functions/array/arrayreverse.md)
* [ArraySet](/boxlang-language/reference/built-in-functions/array/arrayset.md)
* [ArrayShift](/boxlang-language/reference/built-in-functions/array/arrayshift.md)
* [ArraySlice](/boxlang-language/reference/built-in-functions/array/arrayslice.md)
* [ArraySome](/boxlang-language/reference/built-in-functions/array/arraysome.md)
* [ArraySort](/boxlang-language/reference/built-in-functions/array/arraysort.md)
* [ArraySplice](/boxlang-language/reference/built-in-functions/array/arraysplice.md)
* [ArraySum](/boxlang-language/reference/built-in-functions/array/arraysum.md)
* [ArraySwap](/boxlang-language/reference/built-in-functions/array/arrayswap.md)
* [ArrayToList](/boxlang-language/reference/built-in-functions/array/arraytolist.md)
* [ArrayToStruct](/boxlang-language/reference/built-in-functions/array/arraytostruct.md)
* [ArrayTranspose](/boxlang-language/reference/built-in-functions/array/arraytranspose.md)
* [ArrayUnique](/boxlang-language/reference/built-in-functions/array/arrayunique.md)
* [ArrayUnshift](/boxlang-language/reference/built-in-functions/array/arrayunshift.md)
* [ArrayZip](/boxlang-language/reference/built-in-functions/array/arrayzip.md)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/array/arraynew.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
