Quantcast
Channel: Programming Forums
Viewing all articles
Browse latest Browse all 51036

Need help with merging arrays

$
0
0
have an assignment that requires me to make ordered string list objects. i currently have 2 ordered string lists, each with 7 string values in them. im trying to create a method that merges list a and b, but I'm missing something, which I cant figure out yet...
here is what i have so far.
my OrderedStringList program:
public boolean merge(OrderedStringList a, OrderedStringList B)/> {
        boolean result = false;
        int i;
        for ( i = 0; i < a.used; i++) {
            insert(a.list[i]);
            result = true;
        }
        for (i = 0; i < b.used; i++) {
            insert(b.list[i]);
            result = true;
        }
        return result;
    }


and in my main program :

OrderedStringList c = new OrderedStringList(2 * 7);
        c.insert("a"); // I don't know if I need to use insert, a method from OrderedStringList where I insert strings
        c.insert("b");
        
        if (c.merge(a,B)/>){
            System.out.println("Merge was successful.");            
        }        


and my output is only showing :Merge was successful. however I want my output to show the strings from list a and list b....

Viewing all articles
Browse latest Browse all 51036

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>