1. Preface
Overview of learning: In the first eight days, we learned the basics of grammar, operators and expressions, loop structures, and branch structures. Today we mainly learn the definition of arrays, related attribute methods, and array storage. Memory diagram, common mistakes
Learning goals: Master the two definition methods of arrays, related properties, understand memory principles, error resolution
2. Definition of arrays
1 .Overview
If the grades of a classmate need to be stored, what method should be used?
As we learned before, multiple variables can be defined to store different scores. But if there are more than 1,000 students, then how about defining more than 1,000 variables? Of course not, this requires using our array.
2. Static initialization of array
Features: Directly assign values to the array when defining it, and the system determines the array length
General format:
Data type [] array name = { element 1, element 2, element 3,... };
For example:
int [] array= {1,2,3,4,5};
double[] scores = {88.5, 99.5, 59.5};
3. Dynamically initialize the array
Features: Determine the type of the element and the length of the array when defining the array, and then Storing data
General format:
Data type[]Array name=new Data type[length];
For example:
int [] array= new int [5];
double[] scores = new double[3];
Default value:
Data type | Specific definition type | Default value |
Basic type | ##byte, short, char, int, long | 0|
float,double | 0.0||
boolean | #false||
Class, interface, array, String | null
The above is the detailed content of Example analysis of how to use Java arrays. For more information, please follow other related articles on the PHP Chinese website!

Discussion on ZipInputStream character set settings Many developers use ZipInputStream to decompress zip compressed packages containing Chinese file names or folder names, �...

Implementing the retry strategy using SpringWebFlux in building an LLM...

JDBC...

Android...

How to avoid repeated execution of timed tasks in SpringBoot multi-node environment? In Spring...

Deeply discussing properties and states in object-oriented programming. In object-oriented programming, the concepts of properties and state are often confused, and there is a subtle between them...

How to deal with digital overflow errors when connecting to Oracle database in IDEA When we are using IntelliJ...

When studying the MyBatis framework, developers often encounter various problems about annotations. One of the common questions is how to use the @ResultType annotation correctly...


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

SecLists
SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

EditPlus Chinese cracked version
Small size, syntax highlighting, does not support code prompt function

Zend Studio 13.0.1
Powerful PHP integrated development environment

SublimeText3 English version
Recommended: Win version, supports code prompts!

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool