Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

how to insert a 0 in an array java

public static int[] addPos(int[] a, int pos, int num) {
    int[] result = new int[a.length];
    for(int i = 0; i < pos; i++)
        result[i] = a[i];
    result[pos] = num;
    for(int i = pos + 1; i < a.length; i++)
        result[i] = a[i - 1];
    return result;
}
Comment

PREVIOUS NEXT
Code Example
Java :: copy text from header tag in javacript 
Java :: java calendar to date 
Java :: how to get string value in java in android 
Java :: bool in java 
Java :: Simple For Loop Java Example 
Java :: initialize empty dictionary java 
Java :: java math random 
Java :: stringbuilder with delimiter java 
Java :: 2-dimensional Array java 
Java :: Card view only top corner radius 
Java :: java questions 
Java :: finding the ascii value of a character in java 
Java :: java static keyword 
Java :: Java How to use ConcurrentMap? 
Java :: Set icon for toolbar android 
Java :: java insertion sort 
Java :: syntax of the switch statement in Java 
Java :: get selected item spinner 
Java :: how to read space separated integers in java 
Java :: how to use java 
Java :: display hello world in android app 
Java :: how to remove leading space in java 
Java :: can we serialize class in java 
Java :: java literals 
Java :: syntax for java interfaces 
Java :: run java class file 
Java :: why the fuck java suck 
Java :: intelij show method information 
Java :: access char in string 
Java :: one space diagonally in java 
ADD CONTENT
Topic
Content
Source link
Name
5+6 =