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
या प्रश्नात किंवा उत्तरात काही त्रुटी आहे का?
