Explain the usage of the following special symbol in Java: [](brackets)
Advertisements
प्रश्न
Explain the usage of the following special symbol in Java:
[](brackets)
स्पष्ट कीजिए
Advertisements
उत्तर
The square brackets [] are used in Java to declare arrays and access their elements. They indicate that a variable can store multiple values of the same data type. Square brackets are also used with an index number to access or modify a particular element of an array. Array indexing in Java starts from 0.
Example:
int marks[] = {10, 20, 30, 40};
System.out.println(marks[0]);
Output:
10
shaalaa.com
क्या इस प्रश्न या उत्तर में कोई त्रुटि है?
