迷新白的博客 迷新白的博客
首页
随笔
  • Vuepress
  • Springboot
  • 开发工具
  • 系统工具
读吧
  • 智能浇花系统 (opens new window)
  • 用户中心系统 (opens new window)
  • 关于
  • 友情链接
GitHub (opens new window)

迷新白

愿你平安
首页
随笔
  • Vuepress
  • Springboot
  • 开发工具
  • 系统工具
读吧
  • 智能浇花系统 (opens new window)
  • 用户中心系统 (opens new window)
  • 关于
  • 友情链接
GitHub (opens new window)
  • 后端基础

  • Java

    • 优化数据库和前端的交互
    • IO流和使用文件流
    • Java类型File和Files的使用
    • Java类型List和Map
    • Java异常处理
    • Java函数split
    • Java数组问题:Array constants can only be used in initializers
  • 后端
  • Java
迷新白
2025-08-04

Java函数split

split提供了两个参数,第一个参数是拆分的标准字符,第二个参数是limit,即需要拆分成几个元素。

拆分之后需要赋值给一个字符串数组,因此拆分之后每个元素独立存储在数组中

String str = "小学,初中,高中,大专,本科,研究生,博士";
String[] buff = str.split(",");
1
2

等修改完后再拼接回去

StringBuilder sb = new StringBuilder();
				for (String part : param) {
					if (part!="0") {
						part+=1;
					}
					sb.append(part).append(",");
				}
				String result = sb.toString();
1
2
3
4
5
6
7
8
更新时间: 2025/8/10 23:19:43
Java异常处理
Java数组问题:Array constants can only be used in initializers

← Java异常处理 Java数组问题:Array constants can only be used in initializers→

最近更新
01
JavaScript计时器
08-09
02
CSS-动画效果
08-09
03
JavaScript文档流
08-09
更多文章>
Theme by Vdoing | Copyright © 2022-2025 迷新白 | 的博客
sitemap icon by Icons8
  • 跟随系统
  • 浅色模式
  • 深色模式
  • 阅读模式