标签:.com ack comm bsp sub str cto subarray ted
1 package template; 2 3 import org.apache.commons.lang3.ArrayUtils; 4 import org.apache.commons.logging.Log; 5 import org.apache.commons.logging.LogFactory; 6 7 /** 8 * Created by wangcong on 2016/7/29. 9 */ 10 public class ArrayUtilsTemplate { 11 private final static Log LOG = LogFactory.getLog(ArrayUtilsTemplate.class); 12 13 public static void main(String[] args) { 14 Integer[] array = {1,2,3,4}; 15 boolean isEmpty = ArrayUtils.isEmpty(array); 16 LOG.info(isEmpty); 17 18 boolean contains = ArrayUtils.contains(array,2); 19 LOG.info(contains); 20 21 Integer[] clone = ArrayUtils.clone(array); 22 LOG.info(ArrayUtils.toString(clone)); 23 24 Integer[] add = ArrayUtils.add(array,5); 25 LOG.info(ArrayUtils.toString(add)); 26 27 Integer[] array2 = {5,6}; 28 Integer[] addAll = ArrayUtils.addAll(add,array2); 29 LOG.info(ArrayUtils.toString(addAll)); 30 31 Integer[] subArray = ArrayUtils.subarray(addAll,2,6); 32 LOG.info(ArrayUtils.toString(subArray)); 33 34 int indexOf = ArrayUtils.indexOf(addAll,5); 35 LOG.info(indexOf); 36 37 //转化成基础类型 38 int[] toPrimitive = ArrayUtils.toPrimitive(addAll); 39 LOG.info(ArrayUtils.toString(toPrimitive)); 40 41 //基础类型转换成对象 42 Integer[] toObject = ArrayUtils.toObject(toPrimitive); 43 LOG.info(ArrayUtils.toString(toObject)); 44 45 ArrayUtils.reverse(addAll); 46 LOG.info(ArrayUtils.toString(addAll)); 47 48 int length = ArrayUtils.getLength(addAll); 49 LOG.info(length); 50 51 String[] toArray = ArrayUtils.toArray("1","2","3"); 52 LOG.info(ArrayUtils.toString(toArray)); 53 54 } 55 56 }
标签:.com ack comm bsp sub str cto subarray ted
原文地址:http://www.cnblogs.com/dacong-/p/6209924.html