Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to realize the static initialization of Java array

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)05/31 Report--

This article mainly introduces "how to realize the static initialization of Java array". In daily operation, I believe many people have doubts about how to realize the static initialization of Java array. Xiaobian consulted all kinds of data and sorted out simple and easy-to-use operation methods. I hope it will be helpful to answer the doubt of "how to realize the static initialization of Java array". Next, please follow the editor to study!

Concept

1. It refers to the execution of the contents of the static initialization block. When you create an array, you determine the element directly.

2. Format

Data type [] array name = new data type [] {element 1, element 2.}

Example

Package com.itheima.array2; public class Demo1Array {/ * array static initialization: specify the initial value of each array element during initialization, and the full format of the array length is determined by the system: data type [] array name = new data type [] {data 1, data 2, data 3.} Simplified format: data type [] array name = {data 1, data 2, data 3.}; * / public static void main (String [] args) {/ / data type [] array name = new data type [] {data 1, data 2, data 3.}; int [] arr = new int [] {112233} System.out.println (arr [0]); System.out.println (arr [1]); System.out.println (arr [2]); / / data type [] Array name = {data 1, data 2, data 3.}; int [] arr2 = {44 System.out.println (arr2); System.out.println (arr2 [0]) System.out.println (arr2 [1]); System.out.println (arr2 [2]);}} at this point, the study on "how to implement static initialization of Java arrays" is over, hoping to solve everyone's doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!

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.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report