- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Get array upperbound in Java Multidimensional Arrays
In order to get the array upperbound of a multidimensional array, we use the length() method. For a 2D array, the length() method returns the number of rows. We can access the number of columns using the array_name[0].length method.
Let us see a program to get the array upperbound in Java Multidimensional arrays
Example
public class Example { public static void main(String args[]) { String[][] str = new String[5][10]; System.out.println("1st dimension : " + str.length); // displays the number of rows System.out.println("2nd dimension : " + str[0].length); // displays the number of columns } }
Output
1st dimension : 5 2nd dimension : 10
Advertisements