java数组字符串 转数组
时间: 2023-09-12 13:04:53 浏览: 126
在Java中,你可以使用split方法将一个字符串分割成一个数组。你可以提供一个分隔符作为参数,这样字符串就会根据该分隔符被分割成多个子字符串,并存储在一个数组中。下面是一个例子:
```java
String str = "0,1,2,3,4,5";
String[] arr = str.split(",");
System.out.println(Arrays.toString(arr));
```
这段代码将会把字符串"0,1,2,3,4,5"按照逗号分隔,得到一个包含这些数字的字符串数组[0, 1, 2, 3, 4, 5]。你可以使用Arrays.toString方法将数组以字符串的形式输出。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* [Java实现数组转字符串及字符串转数组的方法分析](https://download.csdn.net/download/weixin_38558246/12758366)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"]
- *2* *3* [java 数组转字符串 字符串转数组](https://blog.csdn.net/sky198989/article/details/86712267)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"]
[ .reference_list ]
阅读全文