Arrays in Java Continued

preview_player
Показать описание
Java tutorial for beginners playlist

Healthy diet is very important both for the body and mind. If you like Aarvi Kitchen recipes, please support by sharing, subscribing and liking our YouTube channel. Hope you can help.

Recap
- What is array
- Java Array features
- Declaring Arrays
- Declaring Multidimensional Arrays
More on Arrays
- Are objects
- length field
Processing Arrays
- For Loop
- For Each Loop
Passing Arrays to Methods
Returning Arrays from Methods
Arrays utility class

Description : Most programming languages give you a way of saving sets of data in memory. These are called collections. In our last tutorial we had shown you how to declare an array with few different types of syntax. To recap - An array is a fixed-size ordered collection. It's fixed-size, because once you declare an array with a certain number of items, you can't change the number of items in that array.

Way to collect multiple values using 1 variable
Fixed sized ordered collection
Used to store collection of same type of variables
Zero indexed arrays
Declaring arrays : datatype[] ref ;
OR datatype ref[] ; ( not preferred )
Creating arrays : ref = new datatype[size] ;
Initializing arrays using { val0, val1, … }
Accessing arrays using notation : arr [ index ]

More on Arrays

- Arrays are actual objects, and are created on the heap, not on stack. We can say that they are objects because we create them using the "new" keyword

- In Java programming language, arrays are objects. They are dynamically created, and may be assigned to variables of type Object. All methods of class Object can be invoked on an array

- Arrays length field

- You can't assign a new item in the array in an index that hasn't already been declared. Because, an array is of a fixed size.

Processing Arrays

- Arrays and for loops are made for each other
- Loops are used to iterate over elements of an array
- For and For Each Loop

Passing Arrays to Methods

Returning Arrays from Methods

Arrays Utility classes

You can also pass arrays to custom methods.

All of the arrays that I've demonstrated so far have been single-dimensional arrays, where the array has a fixed number of items and each item is an object of some kind, a string, a number, and so on. In Java you can also create multidimensional arrays. These are arrays where each item in the array is also an array, and it's a good way to store a matrix of information. I'll show a demonstration of using multidimensional arrays using code to print mid left, mid center etc
Рекомендации по теме
Комментарии
Автор

nice one sir, easy to understand, keep going 👍👍

SmartProgramming
Автор

Thank you sir, we respect your effort.

shaswat