java String[]
时间: 2024-01-03 16:05:29 浏览: 21
String[] is an array of strings in Java. It is a data structure that allows you to store and manipulate a group of strings in a single variable. The elements of a String[] array can be accessed and manipulated individually using their index values. Here is an example of how to declare and initialize a String[] array in Java:
String[] fruits = {"apple", "banana", "orange", "grape"};
This creates a String[] array with four elements, each containing a different fruit name. You can access the individual elements of this array using their index values:
System.out.println(fruits[0]); // prints "apple"
System.out.println(fruits[2]); // prints "orange"
You can also loop through the elements of a String[] array using a for loop:
for (int i = 0; i < fruits.length; i++) {
System.out.println(fruits[i]);
}
This will print out all the elements of the fruits array in order.
相关推荐
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![-](https://csdnimg.cn/download_wenku/file_type_column_c1.png)
![-](https://csdnimg.cn/download_wenku/file_type_column_c1.png)
![-](https://csdnimg.cn/download_wenku/file_type_column_c1.png)
![-](https://csdnimg.cn/download_wenku/file_type_column_c1.png)
![-](https://csdnimg.cn/download_wenku/file_type_column_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)