2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

【commons-lang3】 ArrayUtils のよく利用する(しそう)メソッド

Posted at

メモ



import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.StringUtils;

public class Main {

	public static void main(String[] args) {

		// 配列の末尾に追加する。(単数)
		int[] array = ArrayUtils.add(ArrayUtils.EMPTY_INT_ARRAY, 1);
		// 配列の末尾に追加する。(複数)
		int[] array4 = ArrayUtils.addAll(array, 2, 3, 4);
		// int -> Integer
		Integer[] array2 = ArrayUtils.toObject(array);
		// Integer -> int
		int[] array3 = ArrayUtils.toPrimitive(array2);

		System.out.println(StringUtils.join(array2, ", "));
		System.out.println(StringUtils.join(array3, ", "));
		System.out.println(StringUtils.join(array4, ", "));
	}
}
2
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?