Powered by Ajaxy
Digg StumbleUpon LinkedIn YouTube Flickr Facebook Twitter RSS Reset

Java: How to resize an array

    	int length = Array.getLength(a);
        Class componentType = a.getClass().getComponentType();
        Object newArray = Array.newInstance(componentType, newLength);

Java: How to resize an array

    	int length = Array.getLength(a);
        Class componentType = a.getClass().getComponentType();
        Object newArray = Array.newInstance(componentType, newLength);
        System.arraycopy(a, 0, newArray, 0, newLength);
        return newArray;

Perl: How to Put one array into another array as an element

#!/usr/bin/perl -w
my @tab1 = (1, 2, 3, 4);       # define an array of 4 elements
my @tab2;                     # define an empty array
@tab2 = (@tab

Perl: iterate over two lists simultaneously

# define two arrays
@tab_a = ( -1, 52, .5, 3.5 );
@tab_b = ( 0, 10, -5, 1 );
foreach $elem (@tab_a, @tab_b)    # iterate over the two arrays
{
    $e

Java: How to search for a specified value of an array

import java.util.Arrays;
public class FindInArray
 {
  public static void main(String[] args)
  	{
    Integer tab[]=	{-1, -2, 3, -4, 5};
    Arrays.s