Arrays | Sololearn: Learn to code for FREE!

+2

Arrays

I don't understand the arrays statements at all... can you please explain? I didn't understand the explanation in Sololearn also...

3/11/2020 7:06:22 PM

Yahel

7 Answers

New Answer

+6

https://code.sololearn.com/cf7PX38NP4tW/?ref=app

+5

Arrays are nothing but objects. In Java you have 8 primitive data types and the rest are reference types. Arrays can hold any of these types. In order to declare an Array, you just have to write the below line- Type[ ] array_name = new Type[size]; // this is called array declaration. You can replace the Type with anything, it could be either primitive types, wrapper classes or even user defined types. A simple example would be- int[ ] abc = new int[ 5 ]; Here you have created an integer type array which can store 5 values of integer type only. To store values you can do- abc[0] = 10; abc[1] = 20; abc[2] = 30; etc... Always remember array indexing starts from 0 so the above array can hold indexes from 0 to 4 which are totally 5 in number.

+2

Avinesh it's a little bit too complicated... I will search it up more later... if I won't understand by then I will tag you in this post.. ty

+1

yahel See if this helps. https://code.sololearn.com/co4xRMBPjQkS/?ref=app

+1

yahel good to hear that ๐Ÿ‘

0

Avinesh thank you for helping so far. Can you please put a simple example in a document (sololearn) and I will see how the output worked and everything...

0

Avinesh I figured it out.. I checked on YouTube... ty