ppp

Java 之 String 引用传递

方法一:

public static void DateTimeToString(String expr, String formatstr ,LocalDateTime now) {

    String re = expr;
    expr = "12345";
    Field valueFieldOfString = null;
    try {

        valueFieldOfString = String.class.getDeclaredField("value");
        valueFieldOfString.setAccessible(true);
        valueFieldOfString.set(re,expr.toCharArray());

    } catch (IllegalAccessException e) {
        e.printStackTrace();
    } catch (NoSuchFieldException e) {
        e.printStackTrace();
    }
}

方法二:使用 StringBuffuer ? StringBuilder ?

posted @ 2021-01-13 17:16  KutsuHaku  阅读(316)  评论(0编辑  收藏  举报
页脚 HTML 代码