Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 5 of 5

Threaded View

  1. #1
    Junior Member
    Join Date
    Nov 2010
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default How to merge an int array then put it in ascending order without any Java APIs

    This is what I have:

    package challengespackage;
     
    public class ArrayMerge {
     
    	public static void main(String[] args) {
    		System.out.print(merge(new int[] { 9, 3, 0 }, new int[] { 4, 7, 8 }));
    	}
     
    	private static int[] merge(int[] iArrOne, int[] iArrTwo) {
    		int[] iArrMerged = new int[iArrOne.length + iArrTwo.length];
     
    		for (int i = 0; i < iArrOne.length; i++) {
    			iArrMerged[i] = iArrOne[i];
    		}
     
    		for (int j = 0; j < iArrTwo.length; j++) {
    			iArrMerged[iArrOne.length + j] = iArrTwo[j];
    		}
     
    		return iArrMerged;
    	}
    }

    So far all it does is combine to two arrays. I am unsure of how to sort the array in ascending order without using any Java APIs like Arrays.sort();. Any help is appreciated!
    Last edited by JBow94; November 6th, 2010 at 11:15 AM.


Similar Threads

  1. how to merge my OO with GUI
    By zyspt in forum AWT / Java Swing
    Replies: 1
    Last Post: May 18th, 2010, 03:28 PM
  2. Sort in Cyrilic order
    By cselic in forum What's Wrong With My Code?
    Replies: 3
    Last Post: May 5th, 2010, 03:08 PM
  3. Merge 2 Sorted Text Files into a Third
    By Epyllion in forum What's Wrong With My Code?
    Replies: 0
    Last Post: February 10th, 2010, 08:24 PM
  4. Java Source/APIs to create a Fourm
    By softwarebuzz in forum Java Theory & Questions
    Replies: 2
    Last Post: January 9th, 2010, 01:46 AM
  5. Stack Order?
    By TimW in forum AWT / Java Swing
    Replies: 2
    Last Post: September 19th, 2009, 07:33 AM