# Array size gets reset

**URL:** <https://forum.katalon.com/t/array-size-gets-reset/80558>\
**Category:** Web Testing\
**Tags:** katalon-studio\
**Created:** [November 12, 2022, 7:12pm UTC](https://forum.katalon.com/t/array-size-gets-reset/80558 "2022-11-12T19:12:37Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![mithun.chakravarthi8](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/mithun.chakravarthi8/32/16104_2.png) [@mithun.chakravarthi8](https://forum.katalon.com/u/mithun.chakravarthi8)\
**Post date:** [November 12, 2022, 7:12pm UTC](https://forum.katalon.com/t/array-size-gets-reset/80558/1 "2022-11-12T19:12:37Z")

</div>

Why often array size gets reset if we declare like below

array\_name = new String[4]  
or  
size\_of\_array = 6  
array\_name = new String[size\_of\_array]

Often while making changes in script and saving noticed that above gets updated to  
array\_name = new String

Please help resolving this

---

<div class="post-metadata">

**Author:** ![kazurayam](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/kazurayam/32/333_2.png) [@kazurayam](https://forum.katalon.com/u/kazurayam)\
**Post date:** [November 13, 2022, 1:18am UTC](https://forum.katalon.com/t/array-size-gets-reset/80558/3 "2022-11-13T01:18:13Z")

</div>

Do you use the “Manual mode” of Test Case editor as well as “Script mode”?

The “Manual mode” does something curious sometimes.

Let me show you an example. You want to create a Test Case using the “Script mode”, like

```auto
array_name = new String[4]

```

 ![スクリーンショット 2022-11-13 10.33.41](https://europe1.discourse-cdn.com/katalon/original/3X/2/5/2567eb0c42038d9f225eb237b23a1944c01eda28.png)

Then you switch the editor to “Manual mode” and do something to edit the test case.

 ![スクリーンショット 2022-11-13 10.34.17](https://europe1.discourse-cdn.com/katalon/original/3X/6/d/6d23fad9e9b12e01fdfa01921ee5173c527bc4a5.png)

Then you may switch the editor back to “Script” mode. Then you would find the line was silently modified to something syntactically broken:

```auto
array_name = new String[]

```

 ![スクリーンショット 2022-11-13 10.34.36](https://europe1.discourse-cdn.com/katalon/original/3X/b/2/b2852181fa5ec3d4b83c6b2ed63a517f33fa22fe.png)

This seems to be a bug of Test Case Editor’s “Manual mode”.

@vu.tran

will you address this as a bug?

---

<div class="post-metadata">

**Author:** ![kazurayam](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/kazurayam/32/333_2.png) [@kazurayam](https://forum.katalon.com/u/kazurayam)\
**Post date:** [November 13, 2022, 1:25am UTC](https://forum.katalon.com/t/array-size-gets-reset/80558/4 "2022-11-13T01:25:50Z")

</div>

Any workaround?

Well, perhaps, you should never switch between “Manual mode” and “Script mode”.

If you want to use “Script mode”, then you should never switch to “Manual mode”.

If you want to use “Manual mode”, then you should stick to it. Never switch to “Script mode”.

In my case, I never use the “Manual mode” as I don’t need it.

---

<div class="post-metadata">

**Author:** ![kazurayam](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/kazurayam/32/333_2.png) [@kazurayam](https://forum.katalon.com/u/kazurayam)\
**Post date:** [November 13, 2022, 6:54am UTC](https://forum.katalon.com/t/array-size-gets-reset/80558/6 "2022-11-13T06:54:42Z")

</div>

There is an effective workaround.

You shouldn’t use array of Strings, like this:

```auto
String[] array_name = new String[3]
array_name[0] = 'aaa'
array_name[1] = 'bbb'
array_name[2] = 'ccc'

```

In modern Java/Groovy, an array of String like `new String[3]` is no longer popular. Nobody uses it. Perhaps, Katalon programmers forgot that Java has the syntax of “`new String[3]`”. So the “Manual mode” has a defect dealing with “`new String[3]`”. I wouldn’t blame them. I never write “`new String[3]`”. Rather, you should write `new ArrayList<String>()` instead.

In Groovy,

```auto
//List<String> varName = ["aaa", "bbb", "ccc"]
List<String> varName = new ArrayList<>()
varName.add("aaa")
varName.add("bbb")
varName.add("ccc")
println varName[0] // => "aaa"
println varName.get(0) // => "aaa"
println varName[1] // => "bbb"
println varName[2] // => "ccc"

```

The statement “`List<String> varName = new ArrayList<>()`” is robust against this Katalon Studio’s bug.

---

<div class="post-metadata">

**Author:** ![mithun.chakravarthi8](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/mithun.chakravarthi8/32/16104_2.png) [@mithun.chakravarthi8](https://forum.katalon.com/u/mithun.chakravarthi8)\
**Post date:** [November 13, 2022, 12:36pm UTC](https://forum.katalon.com/t/array-size-gets-reset/80558/7 "2022-11-13T12:36:40Z")

</div>

Thanks @kazurayam for the details and suggestions.

---

<div class="post-metadata">

**Author:** ![vu.tran](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/vu.tran/32/20584_2.png) [@vu.tran](https://forum.katalon.com/u/vu.tran)\
**Post date:** [November 16, 2022, 2:48am UTC](https://forum.katalon.com/t/array-size-gets-reset/80558/8 "2022-11-16T02:48:28Z")

</div>

Hi @kazurayam,

I already informed the support team to categorize this issue. Thanks for noticing me.

Best,
