top of page
Search
  • Writer's pictureMasihini Team

Arrays and Multidimensional Variables


In order to use arrays first we declare a variable as usual, but instead of inserting the type and then the semicolon we write the dimensions it is going to contain.


As we see in the image above, the variable myArr is an array of type int with two dimensions, each of size 10. Therefore it will contain 100 spaces in memory where you can store values.


An array can be used for doing operarations just as any other variable! But instead, you have to index its dimensions.


This arrays go from 0 to n, this means that if they have a dimension of size 10, you have to access it from 0 to 9 -> myArr[0][9]. if you try to access it from myArr[10][10] it will cause a runtime error of Index out of Bounds.


In the next example we see different uses for arrays:


Try it yourself!


4 views0 comments

Recent Posts

See All

Comments


bottom of page