Merge array help..

i made a simple program to merge arrays..it doesnt work for some reason..i post the code..can anyone help me fix it..thanks!
public class Merging {
  public static void main (String [] args) {
    int [] list = {2, 6, 8, 4, 5, 9, 7, 6, 3, 1, 0};
    int [] list2 = {5, 6, 9, 8, 5, 1, 2, 3, 4, 9, 5, 6};
    int [] list3 = new int[list.length + list2.length];
    for (int i = 0; i < list3.length; i++) {
      list3[i] = list[i] + list2;
System.out.print(list3[i]);
Message was edited by:
antonio_montana

for (int i = 0; i < list1.length; i++) {
      list3[i] = list1;
for (int i = 0; i < list2.length; i++) {
list3[i + list1.length] = list2[i];
Definately not the cleanest way, but...

Similar Messages

  • Need help: merge array

    Hi everybody
    Need help in merging array of strong edges (coordinates).
    Already using array in 'if else' but have problem in merging those sequence values into two arrays of x and y coordinates (it will take all coordinates in image).
    Any ideas?
    Thanks.
    mySiti
    for (int i = 0; i < width; i++) { //for width
                for (int j = 0; j < height; j++) { //for height
                    Color c = pic.get(i, j);
                    int r = c.getRed();
                    int g = c.getGreen();
                    int b = c.getBlue();
                   int finalEdgeR=0, finalEdgeG=0, finalEdgeB=0;
                   int notEdgeR, notEdgeG, notEdgeB;
                   int [] StrongEdgeCoordX = new int ;
    int [] StrongEdgeCoordY = new int [j];
    if(r>=50 && r<=255)
    finalEdgeR=r;
    System.out.println("--------------------------------");
    System.out.println("coordinate of this pixel '"+i+"'");
    System.out.println("coordinate of this pixel '"+j+"'");
    System.out.println("StrongEdgeCoordX '"+i+"'");
    System.out.println("StrongEdgeCoordY '"+j+"'");
    System.out.println("edge red '"+finalEdgeR+"'");
    else if (r>=0 && r<50) notEdgeR=0;
    if(g>=50 && g<=255)
    finalEdgeG=g;
    System.out.println("edge green '"+finalEdgeG+"'");
    else if (g>=0 && g<50) notEdgeG=0;
    if(b>=50 && b<=255)
    finalEdgeB=b;
    System.out.println("edge blue '"+finalEdgeB+"'");
    else if (b>=0 && b<50) notEdgeB=0;

    hi, i have here a codes but i dont know on how to print the value that stored in array C;
    heres the sample code;
    // your array a and b
    int[] a, b;
    // you fill them
    a = ...;
    b = ...;
    // now you merge them
    int cSize = a.length + b.length;
    int[] c = new int[cSize];
    // pos of the c array
    int count = 0;
    int i = 0;
    for(i = 0; i < a.length; i++){
    c[count++] = a;
    for(i = 0; i < b.length; i++){
    c[count++] = b[i];

  • Merge arrays of integers

    Hi,
    I hope someone can help me with a method which merges two arrays of intgers. The main idea is to
    divide a array into two almost exact lenghts, sort those arrays and then merge the two sorted arrays.

    int[] intArray;
    int[] int_Array;
    int lenIntArray=intArray.length;
    int lenInt_Array=int_Array.length;
    //Merged Array with length equal to the sum of arrays to be merged.
    int[] mergedArray=new int[lenIntArray+lenInt_Array];
    //Copy arrays into merged array
    for(int i=0; i<lenIntArray; i++)
    mergedArray=intArray[i];
    for(int i=lenIntArray, j=0; i<lenIntArray+lenInt_Array; i++, j++)
    mergedArray[i]=int_Array[j];

  • Why does RoboHelp 8 crash when compiling merged HTML help after deleting a child project in TOC

    Why does RoboHelp 8 crash when compiling merged HTML help after deleting a child project in TOC? I would be grateful for any assistance.
    Here's the situation:
    -- I recently upgraded from RoboHelp X5 to RoboHelp 8. I upgraded my projects to RoboHelp 8 projects.
    -- One large help system I manage is built such that there is one master project and about 25 child projects. Each of these is its own item in the master project TOC.
    -- In RoboHelp X5 I never had any trouble deleting these.
    -- However now in RoboHelp 8, whenever I delete one (by opening TOC pod, right-clicking on item in question, and clicking Delete), and proceed to "Generate Primary Layout" (MS HTML Help), the generation/compilation process proceeds as far as "Generating full-text search data" and then the whole program crashes!
    Am I doing something wrong? Is there a bug in the software? I have installed patches 8.0.1 and 8.0.2.
    Once again, I thank you in advance for any pointers.
    Matthew Keranen
    Jamsa, Finland

    That does help - thanks a lot.
    Wayne Kroger
    State Street Corporation
    SQA-Princeton
    (609) 580-6264
    mail to: [email protected]
    The information contained in this email and any attachments have been classified as limited access and/or privileged State Street information/communication and is intended solely for the use of the named addressee(s). If you are not an intended recipient or a person responsible for delivery to an intended recipient, please notify the author and destroy this email. Any unauthorized copying, disclosure, retention or distribution of the material in this email is strictly forbidden.

  • File Merging --- Need Help

    Greetings,
    I am pretty new at this program, and I am trying to understand how to do my homework assignment. So I do not need the full code, just some help on how to get started.
    I am trying to write a program that merges all files together whose names match a certain pattern, and writes the result to an output file. The input-file pattern will consist of a combination of "normal" filename characters and question marks (?). A question mark in the input-file pattern denotes a single-character "wild card". Thus, the pattern ab?c?.txt would denote all file names that consist of 9 characters such that:
    the first two characters are ab
    the fourth character is c
    the last four characters are .txt
    For example, this would include filenames such as abxc7.txt and abqcc.txt.
    So if there are files in a folder, for example, called abc.txt, adc.txt, cat.txt, and the contents of each has two similar lines of "This is File ZZZ" Where ZZZ represents the name of the file. Then running the program with the pattern a??.txt and the output file finished.txt will result in the file finished.txt having the contents
    This is file abc.txt.
    This is file abc.txt.
    This is file abd.txt.
    This is file abd.txt.
    I don't really know where to begin here. Could you help me out? Thanks

    Check out the API docs for java.io.File. It has methods to list all the files in a particular directory.
    For the name matching, you can create a class that implements FileFilter or FileNameFilter that you then pass to these methods.
    The filter's accept method would test the file name against your criteria.
    (You wouldn't have to use the filter. You could just iterate over the files and compare each one yourself.)
    To do the actual comparison, you could use the String.matches() method or you could just do the character by character comparison yourself.
    If you google for java io tutorial you should find something that will help you with the File class, and java regex tutorial for String.match()
    Break the problem into small pieces, and get each one working before moving onto the next.
    First write a method that takes in a pattern "a?bc?.txt" and a String (that represents a filename) and returns true or false depending on whether it mathes.
    Then write a method that takes the patten and an array or List of Strings or Files and uses the first method to return an array or List of Strings or Files that represents the subset of the original list that matched.
    Post again if you have specific questions about specific parts that you don't understand or cant' get to work.

  • Loops and Arrays help

    Hi,
    I'm a freshman in college and new to java. I am completely lost and really need help with a current assignment. Here are the instructions given by my teacher...
    Building on provided code:
    Loops and Arrays
    Tracking Sales
    Files Main.java and Sales.java contain a Java application that prompts for and reads in the sales for each of 5 salespeople in a company. Files Main.java and Sales.java can be found here http://www.ecst.csuchico.edu/~amk/foo/csci111/labs/lab6N/Main.java
    and here http://www.ecst.csuchico.edu/~amk/foo/csci111/labs/lab6N/Sales.java It then prints out the id and amount of sales for each salesperson and the total sales. Study the code, then compile and run the program to see how it works. Now modify the program as follows:
    1. (1 pts) Compute and print the average sale. (You can compute this directly from the total; no new loop is necessary.)
    2. (2 pts) Find and print the maximum sale. Print both the id of the salesperson with the max sale and the amount of the sale, e.g., "Salesperson 3 had the highest sale with $4500." Note that you don't necessarily need another loop for this; you can get it in the same loop where the values are read and the sum is computed.
    3. (2 pts) Do the same for the minimum sale.
    4. (6 pts) After the list, sum, average, max and min have been printed, ask the user to enter a value. Then print the id of each salesperson who exceeded that amount, and the amount of their sales. Also print the total number of salespeople whose sales exceeded the value entered.
    5. (2 pts) The salespeople are objecting to having an id of 0-no one wants that designation. Modify your program so that the ids run from 1-5 instead of 0-4. Do not modify the array-just make the information for salesperson 1 reside in array location 0, and so on.
    6. (8 pts) Instead of always reading in 5 sales amounts, allow the user to provide the number of sales people and then create an array that is just the right size. The program can then proceed as before. You should do this two ways:
    1. at the beginning ask the user (via a prompt) for the number of sales people and then create the new array
    2. you should also allow the user to input this as a program argument (which indicates a new Constructor and hence changes to both Main and Sales). You may want to see some notes.
    7. (4 pts) Create javadocs and an object model for the lab
    You should organize your code so that it is easily readable and provides appropriate methods for appropriate tasks. Generally, variables should have local (method) scope if not needed by multiple methods. If many methods need a variable, it should be an Instance Variable so you do not have to pass it around to methods.
    You must create the working application and a web page to provide the applications information (i.e., a page with links to the source code, the javadoc and an object model) to get full credit. You can use the example.html's from the last two labs to help you remember how to do this.
    I'm not asking for someone to do this assignment for me...I'm just hoping there is someone out there patient and kind enough to maybe give me a step by step of what to do or how to get started, because I am completely lost from the beginning of #1 in the instructions.
    Any help would be much appreciated! Thank you!
    Message was edited by:
    Scott_010
    Message was edited by:
    Scott_010

    First ask the person who gave this asignment as to why do you require two classes for this , you can have only the Sales.java class with main method in it . Anyways.
    Let Main.java have a main method which instanciates a public class Sales and calls a method named say readVal() in Sales class.
    In the readVal method of sales class define two arrays i.e ids and sales. Start prompting the user for inputting the id and sales and with user inputting values keep storing it in the respective arrays .. Limit this reading to just 5 i.e only 5 salesPerson.
    Once both the arrays are populated, call another method of Sales class which will be used for all computations and output passing both the arrays.
    In this new method say Compute() , read values from array and keep calculating total,average and whatever you want by adding steps in just this loop. You can do this in readval method too after reading the values but lets keep the calculation part seperate from input.
    You must create the working application and a web page to provide the applications information (i.e., a page with links to the source code, the javadoc and an object model) to get full credit. You can use the example.html's from the last two labs to help you remember how to do this. I think this is ur personal stuff , but if you want to use web page , you probably will require to use servlet to read values from the html form passed to the server.

  • Cannot get simple merged HTML Help project going with context sensitive help

    I have built a very simple project in RH9 from scratch, consisting of a main project and a sub-project now after I have modified our large project in changing every hyphens from file and directory names over a couple of days now only to see that context help still doesn't work.
    The map IDs are not visible in the main project. To test it in the example, invoke the CSH-Test (context sensitive help test) from the Toolbox, enter !SSL!\Microsoft_HTML_Help\main.chm in the Offline field  and a number 57 in the ID field. In our large project I'm getting nothing (no window pops up). In this example I'm getting this mystical error box, saying HH_HELP_CONTEXT called without a [MAP] section.
    Christoph

    Hi William,
    thanks having a look at my problem. I read in another thread today a description which comes close to the problem I'm facing.
    Maybe I formed the mini sample not exactly as our problem is situated. (thus the doubled map ids you were claiming).
    I will try to explain again: we have a couple of CHMs in separate single help projects. These go into their own TOCs, Index Glossar etc. like in sub1->Einzel. For the merged project we produce a chm that goes into the directory of the master (main) project, like in sub1->Primäres Layout.
    Each Topic in the sub project (e.g. sub1->Erstes Thema) has a symbolic link address (e.g. "Linkadresse=det_org_angaben), which is mapped to the MAP ID via the .h file.
    This all used to work that way in RH5.
    Now it seems that this information between the map ID and the symbolic Linkaddress gets lost with the merge process.
    I am not using the same ID (57) twice in my example. The MAP ID in the main project comes from the sub1 project (see the yellow locked MAP ID).
    The simplest test is using the CSH-Test in the Toolbox giving the main.chm as the Helpfile to test and enter the 57 as a MAP ID.
    The idea behind is to use one CHM later to have to open in the application. The other CHMs of the subprojects only need to be present in the application directory. Then you invoke HtmlHelp(with the MAPID),like I posted in this thread.
    The method you are suggesting in mapping the ID to the topic in the main project will not work since the topic is in the CHM of the sub project.
    I modified the sample project once again (somehow the baggage files were not showing) to come closer to the constellation we are using in the large project, though I'm getting the "HH_HELP_CONTEXT called without a [MAP] section" error (which does not occur in our large project).
    Christoph

  • Reading from a text file in to an array, help please

    I have the following
    public class date extends Loans{
    public int dd;
    public int mm;
    public int yyyy;
    public String toString() {
    return String.format( "%d,%d,%d", mm, dd, yyyy );
    public class Loans extends Borrowing {
    public String name;
    public String book;
    public date issue;
    public char type;
    public String toString(){
    return String.format( "%s, %s, %s, %s", name, book, issue, type );
    import java.util.Scanner;
    import java.io.*;
    public class Borrowing extends BorrowingList {
    private Loans[] Loaned = new Loans[20];
    if i want to read in from a text file in to that array how do i do it?

    sorry to keep bothering you and thanks loads for your help but now I am getting the following error mesage
    C:\Documents and Settings\MrW\Menu.java:43: cannot find symbol
    symbol : class IOException
    location: class Menu
    }catch(IOException e){
    Note: C:\Documents and Settings\MrW\Borrowing.java uses unchecked or unsafe operations.
    Note: Recompile with -Xlint:unchecked for details.
    1 error
    BUILD FAILED (total time: 0 seconds)
    for this line
    }catch(IOException e){                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • Child of a child merged HTML help not searchable

    In the help for Robohelp the ability to merge projects talks about the ability to merge project B into A and then A into C for example. This works very well for a single level merge for both TOC and index/search (doing all the right things). However, it appears the binary indexing does not work beyond one level. I cannot get project B (third level project merged ok into A) to be index/searched into a parent two levels up (C). The TOC works fine for all levels. Is this a limitation of the binary indexing? Is there a workaround? Currently using Robohelp 8 for HTML.

    Are you producing CHMs? If so, I remember having fun and games trying to get this to work some time ago. I gave up in the end as CHMs were never really designed to work in this way and it created so many issues. I think you'll find that the engine used to create CHMs just can't handle multi-layered merged TOCs.
      The RoboColum(n)
      @robocolumn
      Colum McAndrew

  • Populating 1D Array, Help with 1 Error

    Hello,
    I have just about finished a program that implements a .txt file containing a few records. The order is an int customerNumber, string firstName, string lastName, and float balance. The snipplet of code posted below is where I believe the problem lies, I just cant figure out where it is. Im not sure if my counter is not working correctly or what. The problem is that I'll input the customer number of the first record and it will output fine, but when I type in any other customer number, it returns null. It is supposed to return null if the customer number is not found in the array. The snipplet of code is posted below and if needed, i will post the entire program. Thanks for any help and feel free to ask questions:
    import java.util.Scanner;
    import java.io.*;
    public class customerList {
         private int count;
         private customerRecord data[];
         public customerList()
         data=new customerRecord[100];
         count=0;
    public void getCustomerList(String fileName) throws IOException
         while(count<100)
         Scanner scan=new Scanner(new File("/Users/kd/Documents/workspace/Assignment1/src/records.txt"));
              int customerNumber=scan.nextInt();
              String firstName=scan.next();
              String lastName=scan.next();
              float balance=scan.nextFloat();
              data[count]=new customerRecord(customerNumber, firstName, lastName, balance);
              count++;
    public customerRecord getCustomer(int customerNumber)
              for(int i=0; i<data.length; i++)
                   if(data.getCustomerNumber()==customerNumber)
                        return data[i];
              return null;

    ahh, i see....stupid mistake. would it still be 'legal' for me to do:
    public void getCustomerList(String fileName) throws IOException
         Scanner scan=new Scanner(new File("/Users/kevindoster/Documents/workspace/Assignment1/src/records.txt"));
         while(count<100)
              int customerNumber=scan.nextInt();
              String firstName=scan.next();
              String lastName=scan.next();
              float balance=scan.nextFloat();
              data[count]=new customerRecord(customerNumber, firstName, lastName, balance);
              count++;
    }or is there a problem with my limitations in the while loop

  • Duplicate calendars need to be merged, please help

    i have duplicate calendars (ie: travel, travel) each one contains different events.  this happened because of some sync issues when i tried to use gmail instead of my .mac account.
    i need to merge these 2 calendars together because i dont' want to loose any data.
    please help!?

    Select one of the calendars. From the File menu choose 'Export...' then 'Export...'; from the sub-menu. This will create an .ics file at the location chosen in the Export dialog.
    From the File menu choose 'Import...' then 'Import...' from the sub-menu. A navigation pane will open: navigate to and choose your exported .ics file.
    iCal will ask you where to import this to. Click the drop-down menu and select the calendar you want to add these events to. Import.
    The events from the first calendar will be added to the second. Be aware that you cannot reverse this process.

  • Can't get footnote numbering to update in a document containing multiple merged files, help!

    I've merged a bunch of files into a single document, nearly 100 pages long. The page numbers updated automatically with no issues, but it seems no matter what I try, I can't get the footnote numbers to sync. Is there a trick to this??
    Please tell me I won't have to go through 80+ pages and link them by hand!! Help ;-(

    Thank you, Peter ... Hopefully this helps!

  • New Builder needs some info K9A Plat. RAID Array help

    This is a new build AMD 64x2 6000+, K9A platinum, Lite On DVD Re Writeable SATA, 2x74Gig WD Raptors in Raid 0, Asus X1950 pro Thermaltake 700 W PSU Crossfire cert.
    BIOS registered my drives, Built array PC Rebooted, Installing Win XP pro Hit F6 install drivers, Format drives, Then before Install  It says that :setup cannot copy the file ahcix86.inf.
    If I skip it, it will install XP but when I try to boot from the hard drive It starts to load XP but crashes to the blue screen of death
    *** Stop: 0x0000007BC ( 0xF78A2524, 0xC0000034, 0x00000000, 0x00000000)
    Has anyone got this error string?
    First RAID array I would very much appreciate any help given.

    Hi!
    Looking at some info on Google and Microsoft site, I cannot find the BC error code, only the error code ending with B. It indicates an error with the boot device. It can be caused by several things.
    Check that you are using the correct device drivers to install Windows
    Also, check the installation CD. It could be that the disk was damaged and that you are missing a crucial file because of that
    You can also try installing Windows again and choose to recover the previous installation.
    If this all does not help, try installing Windows on a single HDD (no raid) to see if that will work.

  • Comparing arrays - help!

    Hello. I've been trying to solve this problem for hours, and I would be most grateful for any help you can give me.
    Basically, I'm trying to compare two arrays of char and tell first how many are the same in the same place (I can do that) and then how many are the same but not in place. However, if there are two of one char in one array, and one of the same char in the other, I only want to count it once.
    The problem is, I can't figure out how to do this. I'm using for loops and then setting the char to 0 if it finds a match. This doesn't work. I tried using a series of if statements but I got weird run time acceptions sometimes, and when I put in more if statements to combat that, 1.) it got too confusing and 2.) still only worked half the time. So I'm back to the for loops.
    Here's what I have:
    for (int j = 0; j<guess1.length; j++){
    for(int k = 0; k<code1.length; k++){
    if(code1[k]== guess1[j]){
    code1[k]=0;
    guess1[j] = 0;
    almost = almost + 1;
    So if the code is BBYG and the guess is BWWY, it should return 1 correct and one almost. It will return the one correct, but then return 3 for the almost. It looks at the B in guess which already returned the correct and find it an almost against both B's. When it should have been set to 0 in the correct for loop.
    Sorry, I ramble a bit. Hope you can help!
    Thanks.

    You're gonna love this.
    Unless you have some annoying and patently backward lecturer who wants you to everything the hard way then get ye nose into:
    1. the Collections framework.
    http://java.sun.com/docs/books/tutorial/collections/index.html
    2. and the Collections class itself.
    http://java.sun.com/javase/6/docs/api/java/util/Collections.html
    Hint: a Map can be used to find the distinct items in a list.

  • Boolean Array-- Help Plz Urgent

    Can i create and initialize an array of booleans like this ?
    Boolean[51] Position = true;
    Thanks... Plz help

    This works:Boolean[] bools = {
        new Boolean(true), new Boolean(true), new Boolean(true), new Boolean(true),
        new Boolean(true), new Boolean(true), new Boolean(true), new Boolean(true),
        new Boolean(true), new Boolean(true), new Boolean(true), new Boolean(true),
        new Boolean(true), new Boolean(true), new Boolean(true), new Boolean(true),
        new Boolean(true), new Boolean(true), new Boolean(true), new Boolean(true),
        new Boolean(true), new Boolean(true), new Boolean(true), new Boolean(true),
        new Boolean(true), new Boolean(true), new Boolean(true), new Boolean(true),
        new Boolean(true), new Boolean(true), new Boolean(true), new Boolean(true),
        new Boolean(true), new Boolean(true), new Boolean(true), new Boolean(true),
        new Boolean(true), new Boolean(true), new Boolean(true), new Boolean(true),
        new Boolean(true), new Boolean(true), new Boolean(true), new Boolean(true),
        new Boolean(true), new Boolean(true), new Boolean(true), new Boolean(true),
        new Boolean(true), new Boolean(true), new Boolean(true)
    };... and, fortunately, so does this:Boolean[] bools = new Boolean[51];
    java.util.Arrays.fill(bools, new Boolean(true));I hope you find this of some help.

Maybe you are looking for

  • Lenovo 3000 G530 Notebook - Windows XP Installation

    I am using Lenovo 3000 G530 Notebook with Windows Vista. Now I wanted change to Windows XP but it is not recognising Hard Drive. Please help me to install XP in my Notebook

  • Append with out duplicates ?xml version="1.0" encoding="UTF-8"? in receiv

    Hi, When I am Using append mode in file adapter,for each file that i send a seperate <?xml version="1.0" encoding="UTF-8"?>  tag is getting generated in the target. eg: File 1 <?xml version="1.0" encoding="UTF-8"?> <DEPT> <name>e1</name> </DEPT> File

  • Lms 3.2 and window server 2008 standard: License Server/Daemon Manager is down

    LMS 3.2 and window server  2008 standard, get error when we try Khi truy nhập vào menu chức năng: License Server/Daemon Manager is down. Please check license.log for more information. access licensing: Error communicating with License Server. License

  • RDP in USE Warning message

    Hi Everyone, Wonder if someone have the same issue and has fixed it. I have one stand-alone host PC that can be accessed using RDP from 2 different stand-alone client PC's at a different time during the 24 hours and each client PC located in differen

  • Can't rename a new reminder list.

    Followed instructions but when I press return, it returns to "untitled". MacBook Pro OS 10.7.5 iCal 5.03