0

How to create an array with size that entered by the user?

22nd Jan 2020, 4:35 AM
Avery Chan
Avery Chan - avatar
4 odpowiedzi
+ 8
I'm not familiar with Java but, please try searching on "google" for these kind of simple questions. Anyways, Like vector in C++ you can implement ArrayList data structure in Java for user input sized arrays. Read more. https://www.geeksforgeeks.org/arraylist-in-java/amp/ To implement user input sized arrays in JS. https://stackoverflow.com/questions/1748794/is-there-an-arraylist-in-javascript
22nd Jan 2020, 4:51 AM
Vinay_GB
Vinay_GB - avatar
+ 6
https://www.sololearn.com/Discuss/177056/?ref=app Ask question in proper format Please use search bar you will get similar questions.
22nd Jan 2020, 6:53 AM
R🍁🇮🇳
R🍁🇮🇳 - avatar
+ 5
May I ask which language are you trying to achieve this in? You tagged both Java and JS, so it wasn't directly clear to us.
22nd Jan 2020, 4:44 AM
Fermi
Fermi - avatar
+ 2
You must use something like this : String[] yourArray = new String[sc.nextInt()]; Here a complete code: https://code.sololearn.com/cTPJBbC5WMgy/?ref=app
22nd Jan 2020, 5:51 AM
Julio Codesal
Julio Codesal - avatar