标签:oid one substring date google sub 用法 from 截取
演示gson数组的序列化和反序列化。
import com.google.gson.Gson; /** * @author yongjar * @date 2020/4/28 */ public class GsonTester { public static void main(String args[]) { // 演示序列化 Gson gson = new Gson(); int[] ints = {1,9,5,8,7}; System.out.println("案例1:" + gson.toJson(ints)); String[] strings = {"123", "456", "789"}; System.out.println("案例2:" + gson.toJson(strings)); // 演示反序列化 int[] ints2 = gson.fromJson("[1,2,3,4,5]", int[].class); String arr=""; for (int i = 0; i <ints2.length ; i++) { arr+=ints2[i] + ","; } //这里的substring方法是截取最后一个逗号 System.out.println("案例3:" + arr.substring(0,arr.length()-1)); } }
标签:oid one substring date google sub 用法 from 截取
原文地址:https://www.cnblogs.com/jamal/p/12881191.html