Results 1 to 2 of 2
  1. #1
    Mayur is offline Member
    Join Date
    Jan 2009
    Posts
    24
    Rep Power
    0

    Default Adding two Arrays

    Hello all. I need some help adding two arrays together. I'm not allowed to use java foundation classes. This is what I have so far but I keep getting array out of bounds error and can't seem to figure out why.

    Java Code:
    	public static String[] union2(String[] a, String[] b) {
    		int l1 = a.length;
    		int l2 = b.length;
    		int n = l1 + l2;
    		int n2 = l1-1;
    		String[] output = new String[l1];
    		System.arraycopy(a, 0, output, 0, l1);
    //		System.arraycopy(b, 0, output, l1, n);
    		System.arraycopy(b, 0, output, n2, n);
    		return output;
    	}

  2. #2
    Mayur is offline Member
    Join Date
    Jan 2009
    Posts
    24
    Rep Power
    0

Similar Threads

  1. Adding Values of 2 Arrays
    By core2duo5252 in forum Java 2D
    Replies: 7
    Last Post: 09-05-2009, 04:50 AM
  2. Arrays
    By hypes057 in forum New To Java
    Replies: 13
    Last Post: 09-04-2009, 11:40 AM
  3. Please help me with arrays!
    By ddrcan in forum New To Java
    Replies: 2
    Last Post: 08-10-2009, 05:30 PM
  4. Help!! With arrays
    By ookie833 in forum New To Java
    Replies: 8
    Last Post: 12-14-2008, 01:57 AM
  5. arrays
    By hasysf in forum New To Java
    Replies: 12
    Last Post: 07-28-2008, 03:38 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •