# Preallocating an Array with a given size in Julia 1.0

**URL:** <https://discourse.julialang.org/t/preallocating-an-array-with-a-given-size-in-julia-1-0/14438>\
**Category:** General Usage\
**Created:** [September 2, 2018, 4:14pm UTC](https://discourse.julialang.org/t/preallocating-an-array-with-a-given-size-in-julia-1-0/14438 "2018-09-02T16:14:42Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![OvidiusCicero](https://avatars.discourse-cdn.com/v4/letter/o/73ab20/32.png) [@OvidiusCicero](https://discourse.julialang.org/u/OvidiusCicero)\
**Post date:** [September 2, 2018, 4:14pm UTC](https://discourse.julialang.org/t/preallocating-an-array-with-a-given-size-in-julia-1-0/14438/1 "2018-09-02T16:14:42Z")

</div>

Hi there,  
I’m trying to preallocate an array of hundred elements of `Float64` just as one would declare in C or something else.

It seems that before the code was `Vector{Float64,1}(1000)` but now I get an error when trying this

---

<div class="post-metadata">

**Author:** ![foobar\_lv2](https://avatars.discourse-cdn.com/v4/letter/f/ee59a6/32.png) [@foobar\_lv2](https://discourse.julialang.org/u/foobar_lv2)\
**Post date:** [September 2, 2018, 4:22pm UTC](https://discourse.julialang.org/t/preallocating-an-array-with-a-given-size-in-julia-1-0/14438/2 "2018-09-02T16:22:44Z")

</div>

`Vector{Float64}(undef,1000)` or `Array{Float64,1}(undef, 1000)`.

It was `Vector{Float64}(1000)` or `Array{Float64,1}(1000)` before. If you use 0.7 then you get depreciation warnings that tell you what to do, compared to 0.6.

---

<div class="post-metadata">

**Author:** ![OvidiusCicero](https://avatars.discourse-cdn.com/v4/letter/o/73ab20/32.png) [@OvidiusCicero](https://discourse.julialang.org/u/OvidiusCicero)\
**Post date:** [September 2, 2018, 4:23pm UTC](https://discourse.julialang.org/t/preallocating-an-array-with-a-given-size-in-julia-1-0/14438/3 "2018-09-02T16:23:25Z")

</div>

thanks!

---

<div class="post-metadata">

**Author:** ![rdeits](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rdeits/32/286_2.png) [@rdeits](https://discourse.julialang.org/u/rdeits)\
**Post date:** [September 2, 2018, 4:48pm UTC](https://discourse.julialang.org/t/preallocating-an-array-with-a-given-size-in-julia-1-0/14438/4 "2018-09-02T16:48:48Z")

</div>

x-ref: [PSA: use Julia 0.7 if you are upgrading](https://discourse.julialang.org/t/psa-use-julia-0-7-if-you-are-upgrading/13321)

---

<div class="post-metadata">

**Author:** ![Seif\_Shebl](https://avatars.discourse-cdn.com/v4/letter/s/eada6e/32.png) [@Seif\_Shebl](https://discourse.julialang.org/u/Seif_Shebl)\
**Post date:** [September 2, 2018, 7:21pm UTC](https://discourse.julialang.org/t/preallocating-an-array-with-a-given-size-in-julia-1-0/14438/5 "2018-09-02T19:21:43Z")

</div>

> [@foobar\_lv2](#):
>
> Array{Float64,1}(undef, 1000)

I think the `1` here is not needed because it is deduced from the dimensions, so just `Array{Float64}(undef, 1000)`.
