What is an array
Q: Write code to save 4 students ' test scores.
A: Simple ah, define 4 variables Bai
Q: That "calculates the exam results of 400 students all year round", swollen
For:.......
array , you can help you to solve the problem properly!!
The array can be understood as a huge "box" in which multiple types of data can be stored sequentially, such as an array of type int scores store 4 students ' scores 650) this.width=650; "src=" http:/ Img.mukewang.com/537074a400017cd905290196.jpg "style=" Border:0px;clear:both; "/>
The elements in the array can be accessed by subscript, and the subscript starts at 0. For example, you can get the first element in the array by scores[0], scores[2] can take the third element 92!
Code:
public class HelloWorld {
public static void Main (string[] args) {
Define an array to save five students ' scores
Int[] scores = {78, 93, 97, 84, 63};
The second score in the output array
System.out.println ("The 2nd result in the array is:" + scores[1]);
}
}
Operation Result:
The 2nd score in the array is: 93
This article is from "Ghost" blog, please make sure to keep this source http://caizi.blog.51cto.com/5234706/1547959
Java Basics---What is an array (29)