动态参数写法:[参数1类.... 参数1]
例:
public static String toJSONString(Object object, SerializerFeature... features) {
return toJSONString(object, DEFAULT_GENERATE_FEATURE, features);
}
SerializerFeature... features 可放入多个SerializerFeature参数。
使用举例:
toJSONString(user,SerializerFeature.PrettyFormat,SerializerFeature.WriteMapNullValue,
SerializerFeature.WriteNullStringAsEmpty,
SerializerFeature.DisableCircularReferenceDetect,
SerializerFeature.WriteNullListAsEmpty)
从SerializerFeature 开始,传入的多个参数,就是SerializerFeature...的作用了,同一个类型,比如不确定放置多少个string,也可以此用法[String... strs]。
注意:动态参数必须放在方法参数的最后位置,且不能多个。