Tool version compatibility problem
An array is a Fixed length of , Contains Same type Of data Container
Correct

This video is interpretive , So I hope you have read the content of this knowledge point , And after writing the corresponding code , Watch with questions , Only in this way can we gain more . It is not recommended to watch the video at the beginning 8 branch 35 second

Step 1 : Declare an array
Step 2 : Create an array
Step 3 : Access array
Step 4 : Array length
Step 5 : practice - Minimum value of array
Step 6 : answer - Minimum value of array

Step 1 :

## Declare an array

top fracture
int[] a; Declared an array variable .
[] Indicates that the variable is an array
int Indicates that each element in the array is an integer
a Is the variable name
But , Just this sentence Declare , Will not create an array

Sometimes it's written as int a[]; There is no difference , Is what kind of pleasing to the eye you see
public class HelloWorld { public static void main(String[] args) { // Declare an array int[] a; } }
```public class HelloWorld {
public static void main(String[] args) {
//  Declare an array
int[] a;
}
}
```
Step 2 :

## Create an array

top fracture
When creating an array , To indicate the length of the array .
new int
Quote concepts ：
If the variable represents an array , For example a, We put a be called quote
Different from the basic type
int c = 5; This is called c Assignment by 5
Declare a reference int[] a;
a = new int;
Give Way a This reference , Point to Array public class HelloWorld { public static void main(String[] args) { // Declare a reference int[] a; // Create a length of 5 Array of , And use references a Point to the array a = new int; int[] b = new int; // At the same time , Point to an array } }
```public class HelloWorld {
public static void main(String[] args) {
// Declare a reference
int[] a;
// Create a length of 5 Array of , And use references a Point to the array
a = new int;

int[] b = new int; // At the same time , Point to an array

}
}
```
Step 3 :

## Access array

top fracture
Array subscript base 0
Subscript 0, Represents the first number in the array public class HelloWorld { public static void main(String[] args) { int[] a; a = new int; a= 1; // Subscript 0, Represents the first number in the array a= 2; a= 3; a= 4; a= 5; } }
```public class HelloWorld {
public static void main(String[] args) {
int[] a;
a = new int;

a= 1;  // Subscript 0, Represents the first number in the array
a= 2;
a= 3;
a= 4;
a= 5;
}
}
```
Step 4 :

## Array length

top fracture
.length attribute The length used to access an array
The array access subscript range is 0 To length -1
Once beyond this range , An array subscript out of bounds exception will be generated public class HelloWorld { public static void main(String[] args) { int[] a; a = new int; System.out.println(a.length); // Print the length of the array a=100; // Subscript 4, Essentially “ The first 5 individual ”, That is, the last a=101; // Subscript 5, Essentially “ The first 6 individual ”, Out of range , An array subscript out of bounds exception is generated } }
```public class HelloWorld {
public static void main(String[] args) {
int[] a;
a = new int;

System.out.println(a.length); // Print the length of the array

a=100; // Subscript 4, Essentially “ The first 5 individual ”, That is, the last
a=101; // Subscript 5, Essentially “ The first 6 individual ”, Out of range  , An array subscript out of bounds exception is generated

}
}
```
Step 5 :

## practice - Minimum value of array

top fracture   Wrong posture , get half the results with double the effort ! Click to see the correct posture for the exercise
First create a length of 5 Array of
Then give each bit of the array a random integer
Through for Cycle , Traverse the array , Find out the smallest value

0-100 of There are many ways to obtain random integers , Here is one of the reference methods :

(int) (Math.random() * 100)

Math.random() Will get a 0-1 Random floating point numbers between , Then multiply by 100, And forcibly convert to integer .
public class HelloWorld { public static void main(String[] args) { int[] a = new int; a = (int) (Math.random() * 100); a = (int) (Math.random() * 100); a = (int) (Math.random() * 100); a = (int) (Math.random() * 100); a = (int) (Math.random() * 100); System.out.println(" Each random number in the array is :"); for (int i = 0; i < a.length; i++) System.out.println(a[i]); System.out.println(" The purpose of this exercise is , Find the smallest value : "); } }
```public class HelloWorld {
public static void main(String[] args) {
int[] a = new int;
a = (int) (Math.random() * 100);
a = (int) (Math.random() * 100);
a = (int) (Math.random() * 100);
a = (int) (Math.random() * 100);
a = (int) (Math.random() * 100);

System.out.println(" Each random number in the array is :");
for (int i = 0; i < a.length; i++)
System.out.println(a[i]);

System.out.println(" The purpose of this exercise is , Find the smallest value : ");
}
}
```
Step 6 :

## answer - Minimum value of array

top fracture
Before looking at the answers , Try to finish it yourself first , See the answer when you encounter a problem , The harvest will be more
Before looking at the answers , Try to finish it yourself first , See the answer when you encounter a problem , The harvest will be more
Before looking at the answers , Try to finish it yourself first , See the answer when you encounter a problem , The harvest will be more
Viewing this answer will cost 3 Points , You currently have a total of Point integral . It doesn't cost extra points to see the same answer . Points increase method Or One time purchase JAVA Base total 0 One answer ( Total required 0 Integral )
Viewing this answer will cost 3 Points , You currently have a total of Point integral . It doesn't cost extra points to see the same answer . Points increase method Or One time purchase JAVA Base total 0 One answer ( Total required 0 Integral )
Account not activated , Limited functionality . Please click activate
This video is interpretive , So I hope you have read the content of this answer , Watch with questions , Only in this way can we gain more . It is not recommended to watch the video at the beginning  public class HelloWorld { public static void main(String[] args) { int[] a = new int; a = (int) (Math.random() * 100); a = (int) (Math.random() * 100); a = (int) (Math.random() * 100); a = (int) (Math.random() * 100); a = (int) (Math.random() * 100); System.out.println(" Each random number in the array is :"); for (int i = 0; i < a.length; i++) System.out.print(a[i] + " "); System.out.println(); int min = 100; for (int i = 0; i < a.length; i++) { if( a[i] < min ) min = a[i]; } System.out.println(" The minimum value found is :" +min); } }

The official account of programming , Follow and get the latest tutorials and promotions in real time , thank you . Q & A area
2021-10-12 Writing method writing method
 And far away about JAVA Basics - Array - Create an array Your questions ```/** * @ClassName Arr * @Description Array review , Find the smallest number in the array * @Date * @Author * @Version 1.0 */ public class Arr { /** * @Description: Traverse and print the array * @Param: [arr] * @return: void * @Author: * @Date: */ public static void soutArr(int[] arr){ for (int i = 0; i < arr.length; i++) { System.out.println("arr = " + arr[i]); } } /** * @Description: Find the minimum number * @Param: [arr] * @return: int * @Author: * @Date: */ public static int minArr(int[] arr) { int min = Integer.MAX_VALUE; for (int i = 0; i < arr.length; i++) { if (min>arr[i]){ min = arr[i]; } } return min; } public static void main(String[] args) { int arr[] = new int; for (int i = 0 ; i < arr.length ; i++){ arr[i] = (int)(Math.random()*100); } soutArr(arr); System.out.println("minArr(arr) = " + minArr(arr)); } } ```

Spicy chicken with vegetables
Pipi
es54

answer Or code please Fill in at least one , If you have a problem , Please ask again , Otherwise, the webmaster may not see

2021-10-04 code
 A feast about JAVA Basics - Array - Create an array - Declare an array Your questions None Pipi
Kion11
Fengtai Wu Qilong
Makino li
package cn; public class Text5 { public static void main(String[] args) { // TODO Automatically generated method stub int[] a=new int; int min; a=(int)(Math.random()*100); a=(int)(Math.random()*100); a=(int)(Math.random()*100); a=(int)(Math.random()*100); a=(int)(Math.random()*100); System.out.println(" Each random number in the array is :"); for(int i=0;i<a.length;i++) { System.out.println(a[i]); min=a; for(int j=0;j<a.length-1;j++) { if(min>a[j+1]) { min=a[j+1]; } } System.out.println(min); } } }

answer Or code please Fill in at least one , If you have a problem , Please ask again , Otherwise, the webmaster may not see

2021-07-04 If you can't start, add a minimum initial value , With the minimum initial value, this big sword , A knife, a child
2021-05-11 java.lang.ArrayIndexOutOfBoundsException: Index 5 out of bounds for length 5 Array out of bounds

Too many questions , Page rendering is too slow , To speed up rendering , Only a few questions are displayed on this page at most . also 142 Previous questions , please Click to view