+ 2

Arrays

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

11th Mar 2020, 7:06 PM
Yahel
Yahel - avatar
7 Respostas
11th Mar 2020, 7:20 PM
Sumit Programmer😎😎
Sumit Programmer😎😎 - avatar
+ 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.
11th Mar 2020, 7:15 PM
Avinesh
Avinesh - avatar
11th Mar 2020, 7:38 PM
Avinesh
Avinesh - avatar
+ 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
11th Mar 2020, 7:44 PM
Yahel
Yahel - avatar
+ 1
yahel good to hear that 👍
12th Mar 2020, 4:36 PM
Avinesh
Avinesh - avatar
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...
11th Mar 2020, 7:27 PM
Yahel
Yahel - avatar
0
Avinesh I figured it out.. I checked on YouTube... ty
12th Mar 2020, 2:51 PM
Yahel
Yahel - avatar