
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Int's concat Function in Java
The concat() function in Ints class is used to concatenate the arrays passed as parameter. The syntax is as follows −
public static int[] concat(int[]... arr)
Here, parameter arr is zero or more integer arrays.
Let us see an example −
Example
import com.google.common.primitives.Ints; import java.util.*; class Demo { public static void main(String[] args) { int[] myArr1 = { 100, 150, 230, 300, 400 }; int[] myArr2 = { 450, 550, 700, 800, 1000 }; System.out.println("Array 1 = "); for(int i=0; i < myArr1.length; i++) { System.out.println(myArr1[i]); } System.out.println("Array 2 = "); for(int i=0; i < myArr2.length; i++) { System.out.println(myArr2[i]); } int[] arr = Ints.concat(myArr1, myArr2); System.out.println("Concatenated arrays = "+Arrays.toString(arr)); } }
Output
Array 1 = 100 150 230 300 400 Array 2 = 450 550 700 800 1000 Concatenated arrays = [100, 150, 230, 300, 400, 450, 550, 700, 800, 1000]
Advertisements