想把builderArray变成字符串使用log.debug("e", builderArray);打印出来,但是为什么无效?

package com.mvc.utils;

import lombok.extern.slf4j.Slf4j;

@Slf4j

public class CommonUtil {

/**

* String 字符串常量

* StringBuffer 字符串变量(线程安全)

* StringBuilder 字符串变量(非线程安全)

*/

public static String handleId(String[] idArr) {

StringBuilder builder = new StringBuilder();

for (String id : idArr) {

builder.append("'").append(id).append("'").append(",");

}

builder.deleteCharAt(builder.length()-1);

return builder.toString();

}

}

package com.mvc;

import com.mvc.utils.CommonUtil;

import lombok.extern.slf4j.Slf4j;

@Slf4j

public class CommonUtilTest {

public static void main(String[] args) {

String[] strArray = new String[]{"abc", "bcd", "cty"};

System.out.println("strArray = " + strArray);

StringBuilder builderArray = new StringBuilder();

CommonUtil.handleId(strArray);

System.out.println("strArray = " + strArray);

}

}

package com.mvc;

import com.mvc.utils.CommonUtil;

import lombok.extern.slf4j.Slf4j;

@Slf4j

public class CommonUtilTest {

public static void main(String[] args) {

String[] strArray = new String[]{"abc", "bcd", "cty"};

StringBuilder builderArray = new StringBuilder();

log.debug("e", strArray);

CommonUtil.handleId(strArray);

}

}

图片描述

打印不出来啊

图片描述

回答:

emmmmm, 兄弟你倒是把处理后的东西拿到手啊 :

log.debug("e", CommonUtil.handleId(strArray));

另外,java 里自带工具方法帮你输出数组的内容:

System.out.println(Arrays.toString(strArray));

以上是 想把builderArray变成字符串使用log.debug("e", builderArray);打印出来,但是为什么无效? 的全部内容, 来源链接: utcz.com/p/174554.html

回到顶部