[Java] I have problem to understand the arrays ? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

[Java] I have problem to understand the arrays ?

What is arrays and what it using for ? Can anyone explain it using some examples.

9th Feb 2022, 8:53 PM
Mrad Houssem
Mrad Houssem - avatar
3 Answers
+ 1
Also imagine you are making a chess game for 8 by 8 board. You would use 2 dimensional array to track the board pieces. It would be the most wise data type to use
10th Feb 2022, 7:03 PM
Talha Altınel (The Last Sith Lord)
Talha Altınel (The Last Sith Lord) - avatar
0
It is a fixed size of same types, not sure what you don't understand
9th Feb 2022, 10:39 PM
Talha Altınel (The Last Sith Lord)
Talha Altınel (The Last Sith Lord) - avatar
0
Imagine you want to store 20 numbers, Strings or whatever. Using 20 variables is possible but too much work. Arrays are like containers/lists with a fixed size. int myArray[] = new int[20] Now you can use this array to store your 20 values. And you can do many other stuff like sorting, searching for a value... Here is a good tutorial with examples: http://tutorials.jenkov.com/java/arrays.html
10th Feb 2022, 3:22 PM
Denise Roßberg
Denise Roßberg - avatar