In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-29 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article focuses on "how to use Java array to achieve dynamic initialization", interested friends may wish to take a look. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn how to use Java array to achieve dynamic initialization.
Concept
1. Array dynamic initialization only gives the array length, and the system initializes the value by default.
2. Format
Data type [] array name = new data type [array length]
Int [] arr = new int [3]; dynamic initialization of the instance package com.itheima.array; public class Demo2Array {/ * array: during initialization, you need to specify the length of the array manually, and the system will assign the initial value to the array container. Dynamic initialization format: data type [] array name = new data type [length of array] Note: when printing array variables The memory address of the array will be printed out [I@10f87f48: @: delimiter]: the current space is an array type I: the data type stored in the current array container 10f87f48: in hexadecimal Storage address 0 1 2 3 4 5 6 7 8 9 a b c d e f * / public static void main (String [] args) {/ / data type [] array name = new data type [length of array] / / create an array container of type int through the new keyword, which can store five integers of type int. The container is recorded by the arr array variable int [] arr = new int [5]; / / [I@10f87f48 System.out.println (arr); byte [] bArr = new byte [3] / / [B@b4c966a System.out.println (bArr);}}
Knowledge point expansion:
1, what is the initialization of an array
Is to open up a continuous memory space for the array and assign a value to each array element
2, how to initialize the array
[1] dynamic initialization only specifies the length, and the initialization value is given by the system.
Int [] arr = new int [5]
[2] static initialization gives the initialization value, and the length is determined by the system.
3. Format of dynamic initialization:
Data type [] array name = new data type [array length]
At this point, I believe you have a deeper understanding of "how to use Java array to achieve dynamic initialization". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.