Java: How to create an Array
Question by Guest | 2016-08-06 at 18:10
What can I do to just create a simple array using the programming language Java? I am coming from other languages and I have tried a lot, but I cannot make it work.
Can someone give me an easy example?
Related Topics
JavaScript: Create and Use Arrays
Info | 0 Comments
PHP: Remove all empty elements from string array
Tip | 0 Comments
Lazarus: Load File as Byte Array and save Byte Array as File
Tutorial | 0 Comments
Send Form Input as an Array to PHP Script
Tip | 0 Comments
PHP: Fill Array with Sequence of Numbers or Characters
Tutorial | 0 Comments
PHP: Write array to individual Variables
Tutorial | 0 Comments
JavaScript: Sort Array of Numbers
Tutorial | 0 Comments
Important Note
Please note: The contributions published on askingbox.com are contributions of users and should not substitute professional advice. They are not verified by independents and do not necessarily reflect the opinion of askingbox.com. Learn more.
Participate
Ask your own question or write your own article on askingbox.com. That’s how it’s done.
In Java, there are several possibilities to create an array.
One-Dimensional Arrays
Here is an example for an integer array:
And here accordingly for a string array:
In each case, the first array (intArr1 respectively strArr1) is directly filled with initial values at creation time. Apart from that, the second array is created as an empty array of defined length that is filled with values later. Afterwards, both integer arrays as well as both string arrays are containing the same values among themselves.
Multidimensional Arrays
Multidimensional Arrays can be created like that:
As you can see, again, we can use those methods - the array mdIntArr1 is immediately initialized with default values, the array mdIntArr2 is filled later.
2016-08-06 at 18:43