In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly shows you "java how to use arrays", the content is easy to understand, clear, hope to help you solve your doubts, the following let the editor lead you to study and learn "java how to use arrays" this article.
Use a simple array
(1) create a class named T04 and declare two variables array1 and array2 in the main () method
They are arrays of type int [].
(2) using curly braces {}, array1 is initialized to 8 primes: 2, 3, 5, 7, 11, 13, 17, 19.
(3) display the content of array1.
(4) assign the array2 variable to be equal to array1, and modify the even index element in array2 to equal the index value (for example, array [0] = 0, array [2] = 2). Print out the array1. * * think: what is the relationship between array1 and array2?
Extension: modify the title to realize the replication of array1 array by array2
Public class T04 {public static void main (String [] args) {int [] array1,array2; array1=new int [] {2, 3, 5, 7, 11, 13, 17, 19}; for (int ionomy 0 teri)
< array1.length;i++){ System.out.print(array1[i]+"\t"); } //赋值array1变量等于array2 //不能称作数组的复制 array2=array1; for(int i=0;i< array1.length;i++){ if(i%2==0){ array2[i]=i; } } System.out.println(); System.out.println("******************************************"); for(int i=0;i< array1.length;i++){ System.out.print(array1[i]+"\t"); } }}(1) both array1 and array2 address values point to the unique array entity in the heap space.
(2)
For (int iTuno Bandi)
< array1.length;i++){ array2[i]=array1[i]; }Method 2
Int iTunes 0; int jung0; for (iTuno Junior j = arr.length-1;i
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.