Blog Introductions
In this blog contains tutorials about HTML Tutorials, Python Tutorials, CSS Tutorials, How to, PHP Tutorials, Java Tutorials, C++ Tutorials, Tutorials, Examples, Source code,Learning,
Tips and Software development services. Java Arrays and their function | Java tutorials Bestitworriors
Java Arrays and their function
Arrays use to hold same type of multiple data in it.When your requirements of having multiple variables and storing large amount of data you need to use array .It will be difficult to store ten values into declearing ten variables and then assign one by one value to ten variables.It will be time consuming and use multiple line of code.Now for overcome this situation you need to implement the java arrays to hold same type of different data in it.
Some Key Points of Java Arrays
- Java arrays hold same type of multiple data
- Arrays same time and reduce lines of codes
- You can access array data using loops
- Array can also access by index of current value
- You can modefy array from the index
- You can perform multiple task in an array
- You can get the length of array using arrayname.length
Code
public class arrayss {
public static void main(String[] args) {
int[][] myNumbers = { {1, 2, 3, 4}, {5, 6, 7} };
for (int i = 0; i < myNumbers.length; ++i) {
for(int j = 0; j < myNumbers[i].length; ++j) {
System.out.println(myNumbers[i][j]);
}
}
String[] Month = {"January", "Feburary", "March", "April"};
for (int i = 0; i < Month.length; i++) {
System.out.println(Month[i]);
}
System.out.println(Month.length);
}
}
Out Put
1
2
3
4
5
6
7
January
Feburary
March
April
4
0 Comments