Java examples for java.lang:int Array
Create a new int[] by concatenating prefix and postfix
/*/*w w w . j a v a 2 s . c o m*/ Copyright 2008-2013 CNR-ISTI, http://isti.cnr.it Institute of Information Science and Technologies of the Italian National Research Council See the NOTICE file distributed with this work for additional information regarding copyright ownership Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ //package com.java2s; public class Main { public static void main(String[] argv) throws Exception { int[] prefix = new int[] { 34, 35, 36, 37, 37, 37, 67, 68, 69 }; int[] postfix = new int[] { 34, 35, 36, 37, 37, 37, 67, 68, 69 }; System.out.println(java.util.Arrays .toString(append(prefix, postfix))); } /** * Create a new <code>int[]</code> by concatenating prefix and postfix * * @param prefix the first the <code>int[]</code> to join * @param postfix the second the <code>int[]</code> to join * @return the new <code>int[]</code> obtained by concatenating prefix and postfix */ public static final int[] append(int[] prefix, int[] postfix) { int[] result = new int[prefix.length + postfix.length]; System.arraycopy(prefix, 0, result, 0, prefix.length); System.arraycopy(postfix, 0, result, prefix.length, postfix.length); return result; } }