String 字符串 转为字符数组

推荐阅读

AI文本 OCR识别最佳实践

AI Gamma一键生成PPT工具直达链接

玩转cloud Studio 在线编码神器

玩转 GPU AI绘画、AI讲话、翻译,GPU点亮AI想象空间

资源分享

史上最全文档AI绘画stablediffusion资料分享

AI绘画关于SD,MJ,GPT,SDXL百科全书

「java、python面试题」来自UC网盘app分享,打开手机app,额外获得1T空间
https://drive.uc.cn/s/2aeb6c2dcedd4
AIGC资料包
https://drive.uc.cn/s/6077fc42116d4
https://pan.xunlei.com/s/VN_qC7kwpKFgKLto4KgP4Do_A1?pwd=7kbv#

String字符型转为字符数组输出

package com.controller;

import com.alibaba.fastjson.JSON;
import net.sf.json.JSONArray;

/**
 * @author zkkstart
 * @create 2019-01-15 17:44
 */
class Solution {

    public static void main(String[] args){
        String jsonStr="a,b,c";
        final String[] split = jsonStr.split(",");
        JSONArray jsonObject = JSONArray.fromObject(split);
        jsonStr = jsonObject.toString();
        System.out.println(jsonStr);
    }
}

运行结果:[“a”,“b”,“c”]

String str = “Hello World”;
char[] charArray = str.toCharArray();

// 打印字符数组
for (char ch : charArray) {
System.out.print(ch + " ");
}

  • 7
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值