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.

Page 1 of 2 12 LastLast
Results 1 to 25 of 27

Thread: It does not return data as it should in the cycle

  1. #1
    Member
    Join Date
    Jun 2017
    Posts
    46
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default It does not return data as it should in the cycle

    I did it this way, but it doesn't verify that the license plates are the same, how come?

    public void confrontaTarghe() throws IOException {
     
    		VeicoloDb veicoloDb = new VeicoloDb();
    		Spinelli spinelli = new Spinelli();
    		int i;
     
    		// Se la Targa veicolo sono uguali Aggiungi ID nella Nuova colonna
    		for (i = 0; i < 280; i++) {
    			for (int j = 0; j < 280; j++) {
    				if (spinelli.getListCellveicoli_targa().get(i).equals(veicoloDb.getListCelltarga().get(j))) {
    					System.out.println(
    							spinelli.getListCellveicoli_targa().get(i) + " =  " + veicoloDb.getListCelltarga().get(i)
    									+ " --> " + i + " --> " + spinelli.getListCellveicoli_id().get(i));
     
    					// Scrivi nella riga i
    					row = sheet.getRow(i);
     
    					// Scrivi nella colonna AC indice 28
    					cell = row.createCell(28);
     
    					// Scrivi il ciclo in tutte le righe nella colonna AC indice 28
    					sheet.getRow(i).createCell(28).setCellValue(spinelli.getListCellveicoli_id().get(i));
     
    					FileOutputStream fos = new FileOutputStream(filePath);
     
    					// Scrivi nel file
    					wb.write(fos);
     
    					// Chiudi il file
    					fos.close();
    					System.out.println("OK");
     
    				}
     
     
    			}
     
    		}
    	}

    methods

    // Lista Spinelli veicoli_targa
    	public ArrayList<String> getListCellveicoli_targa() {
    		for (int rowIndex = 1; rowIndex < 281; rowIndex++) {
    			currentRow = dataTypeSheet.getRow(rowIndex);
    			cell_veicoli_targa = currentRow.getCell(32); // Cella AG
    			veicoli_targa.add(cell_veicoli_targa.getStringCellValue());
    		}
    		return veicoli_targa;
    	}
    methods

    // Lista targa
    	public ArrayList<String> getListCelltarga() {
    		for (int rowIndex = 1; rowIndex < 281; rowIndex++) {
    			currentRow = dataTypeSheet.getRow(rowIndex);
    			cell_targa = currentRow.getCell(11); // Cella L
    			targa.add(cell_targa.getStringCellValue());
    		}
    		return targa;
    	}



    the index is 281 in excel


    if the wipers are the same, I must print only the same number plates.
    Does it print everything to me?

  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,162
    Thanks
    65
    Thanked 2,725 Times in 2,675 Posts

    Default Re: It does not return data as it should in the cycle

    Can you copy the full contents of the console and paste it here so we can see what the program prints out?
    Add some comments to the print out to show what is wrong with it
    and show what the desired output is.

    The get methods that return the ArrayLists should called one time outside of the loops and the lists used in the loop. It looks like the get methods are call hundreds of times inside the loops.

    To debug the code you need to print out the values returned by the get methods that are being compared in the if statement. Seeing what is being compared will help you find the problem.
    However the lists are too big (280x280) so for testing you need to create special, smaller lists that have about 5 elements in them so that there are only 5x5 print outs.
    If you don't understand my answer, don't ignore it, ask a question.

  3. #3
    Member
    Join Date
    Jun 2017
    Posts
    46
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: It does not return data as it should in the cycle

    The first 20 me prints well the same plates. Then going ahead does not make the comparison and I print the plates not equal index i and j

    FR727XD = FR727XD --> 0 --> 25875
    OK
    FN871AM = FN871AM --> 1 --> 25874
    OK
    FN712MX = FN712MX --> 2 --> 25873
    OK
    FL966WE = FL966WE --> 3 --> 25872
    OK
    FL965WE = FL965WE --> 4 --> 25871
    OK
    FL964WE = FL964WE --> 5 --> 25870
    OK
    FL963WE = FL963WE --> 6 --> 25869
    OK
    FL962WE = FL962WE --> 7 --> 25868
    OK
    FL893WE = FL893WE --> 8 --> 25867
    OK
    FL892WE = FL892WE --> 9 --> 25866
    OK
    FL891WE = FL891WE --> 10 --> 25865
    OK
    FL890WE = FL890WE --> 11 --> 25864
    OK
    FL889WE = FL889WE --> 12 --> 25863
    OK
    FL721WE = FL721WE --> 13 --> 25862
    OK
    FL720WE = FL720WE --> 14 --> 25861
    ........
    .......
    ET713YE = ET433TE --> 127 --> 25751
    OK
    ET527GV = ET352HR --> 128 --> 25750
    OK
    ET478TG = ET351HR --> 129 --> 25749
    OK
    ET433TE = ET350HR --> 130 --> 25748
    OK
    ET352HR = ET349HR --> 131 --> 25747
    OK
    ET351HR = ET348HR --> 132 --> 25746
    OK
    ET350HR = ET347HR --> 133 --> 25745


    Can you help me to correct the code please?

    --- Update ---

    ET350HR = ET347HR --> 133 --> 25745 -->This would be the id of the license plate 25745


    I only do the control with the license plate, I remind you that the data are two excel files with identical license plates and identical ids.
    In the first file there are 281 records
    In the second file there are 267 records

  4. #4
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,162
    Thanks
    65
    Thanked 2,725 Times in 2,675 Posts

    Default Re: It does not return data as it should in the cycle

    I don't know what is shown in the print out. Can you post the code that has the print statement that created the print out?

    Can you explain what is shown to be wrong with what the program prints out?
    Is there some data shown in the print out that the program is not handling correctly?
    Where should the results be different?
    If you don't understand my answer, don't ignore it, ask a question.

  5. #5
    Member
    Join Date
    Jun 2017
    Posts
    46
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: It does not return data as it should in the cycle

    public void confrontaTarghe() throws IOException {
     
    		VeicoloDb veicoloDb = new VeicoloDb();
    		Spinelli spinelli = new Spinelli();
    		int i,j;
    		for (i = 0; i < 280 ; i++) {
    			for (j = 0; j < 280 ; j++) {
    				if (spinelli.getSpinelliTarga().get(i).equals(veicoloDb.getVeicoloTarga().get(j))) {
    					System.out.println(
    							spinelli.getSpinelliTarga().get(i) + " =  " + veicoloDb.getVeicoloTarga().get(i)
    									+ " --> " + i + " --> " + spinelli.getListCellveicoli_id().get(i)
    									+ " --> " + veicoloDb.getListCellId().get(j));
     
    					// Scrivi nella riga i
    					row = sheet.getRow(i);
     
    					// Scrivi nella colonna AC indice 28
    					cell = row.createCell(28);
     
    					// Scrivi il ciclo in tutte le righe nella colonna AC indice 28
    					sheet.getRow(i).createCell(28).setCellValue(spinelli.getListCellveicoli_id().get(i));
     
    					FileOutputStream fos = new FileOutputStream(filePath);
     
    					// Scrivi nel file
    					wb.write(fos);
     
    					// Chiudi il file
    					fos.close();
    					System.out.println("OK");
     
    				}
     
     
    			}
     
    		}


    this is the print code


    when i do the if, it has to print only the same license plates and nothing else

    --- Update ---

    BP377GT = FR727XD --> 0 --> 25610 --> 25875
    OK
    BV469PE = FN871AM --> 1 --> 25611 --> 25874
    OK
    BV475PE = FN712MX --> 2 --> 25612 --> 25873
    OK
    BV649PE = FL966WE --> 3 --> 25613 --> 25872
    OK
    BV790PE = FL965WE --> 4 --> 25614 --> 25871

  6. #6
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,162
    Thanks
    65
    Thanked 2,725 Times in 2,675 Posts

    Default Re: It does not return data as it should in the cycle

    print only the same license plates
    Is that (the same license plates) what this statement tests for?
    				if (spinelli.getSpinelliTarga().get(i).equals(veicoloDb.getVeicoloTarga().get(j))) {
    I don't understand what is wrong. Can you post some print out that shows the problem? Be sure to add comments on the lines in the print out where the problem is shown and describe what the problem is.

    --- Update ---

    One problem I see in the code is the use of variable names: i and j
    Those variables do not say what values they contain.
    Better names would be:
    spinelliIndex instead of i
    and veicoloIndex instead of j
    If you make those changes you will see the problem.
    If you don't understand my answer, don't ignore it, ask a question.

  7. #7
    Member
    Join Date
    Jun 2017
    Posts
    46
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: It does not return data as it should in the cycle

    This is the index in excel: veicoloDb.getListCellId()
    in the excel file the index is 267
    id
    25610
    25611
    25612
    25613
    25614
    25615
    25616
    25617
    25618
    25619
    25620


    this is the code

    public ArrayList<String> getListCellId() {
    		for (int rowIndex = 1; rowIndex < 266; rowIndex++) {
    			currentRow = dataTypeSheet.getRow(rowIndex);
    			cell_id = currentRow.getCell(0); // Cella A
    			id.add(cell_id.getStringCellValue().toString());
    		}
    		return id;
    	}


    Instead for the other, the id list is:
    in the excel file the index is 281
    veicoli::id
    25610
    25611
    25612
    25613
    25614
    25615
    25616
    25617
    25618
    25619
    25620
    25621
    25622

    public ArrayList<String> getListCellveicoli_id() {
    		for (int rowIndex = 1; rowIndex < 281; rowIndex++) {
    			currentRow = dataTypeSheet.getRow(rowIndex);
    			cell_veicoli_id = currentRow.getCell(27); // Cella AB
    			veicoli_id.add(cell_veicoli_id.getStringCellValue().toString());
    		}
    		return veicoli_id;
    	}

    Maybe if I understand correctly the problem is in the index, I don't know how I can solve it

  8. #8
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,162
    Thanks
    65
    Thanked 2,725 Times in 2,675 Posts

    Default Re: It does not return data as it should in the cycle

    the problem is in the index
    I think so.
    Did you make the changes I suggested?
    Change i and j in these statements (and the following statements as needed) to the names I suggested
    		for (i = 0; i < 280 ; i++) {
    			for (j = 0; j < 280 ; j++) {

    Post the new code with the above changes.
    If you don't understand my answer, don't ignore it, ask a question.

  9. #9
    Member
    Join Date
    Jun 2017
    Posts
    46
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: It does not return data as it should in the cycle

    public void confrontaTarghe() throws IOException {
     
    		VeicoloDb veicoloDb = new VeicoloDb();
    		Spinelli spinelli = new Spinelli();
    		int i,j;
    		// Se la Targa veicolo sono uguali Aggiungi ID nella Nuova colonna
    		for (i = 0; i <spinelli.getListCellid().size() ; i++) {
    			for (j = 0; j < veicoloDb.getListCellId().size() ; j++) {
    				if (spinelli.getSpinelliTarga().get(i).equals(veicoloDb.getVeicoloTarga().get(j))) {
    					System.out.println(
    							spinelli.getSpinelliTarga().get(i) + " =  " + veicoloDb.getVeicoloTarga().get(i));

    the print is this:

    BP377GT = BP377GT
    OK
    BP377GT = BP377GT
    OK
    BP377GT = BP377GT
    OK
    BP377GT = BP377GT
    OK
    BP377GT = BP377GT


    But it does not work. You can kindly correct the code for me


    do you mean this way?

    public void confrontaTarghe() throws IOException {
     
    		VeicoloDb veicoloDb = new VeicoloDb();
    		Spinelli spinelli = new Spinelli();
    		int i,j;
    		// Se la Targa veicolo sono uguali Aggiungi ID nella Nuova colonna
    		for (i = 0; i < 280; i++) {
    			for (j = 0; j < 267; j++) {
    				if (spinelli.getSpinelliTarga().get(spinelli.getListCellid().size()).equals(veicoloDb.getVeicoloTarga().get(veicoloDb.getListCellId().size()))) {
    					System.out.println(
    							spinelli.getSpinelliTarga().get(spinelli.getListCellid().size()) + " =  " + veicoloDb.getVeicoloTarga().get(veicoloDb.getListCellId().size()));

    error:

    Exception in thread "main" java.lang.IndexOutOfBoundsException: Index: 280, Size: 280
    	at java.util.ArrayList.rangeCheck(ArrayList.java:657)
    	at java.util.ArrayList.get(ArrayList.java:433)
    	at it.nexid.Confrontare.confrontaTarghe(Confrontare.java:53)
    	at it.nexid.SpinelliTest.main(SpinelliTest.java:13)
    Last edited by glprobot; July 12th, 2019 at 10:19 AM.

  10. #10
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,162
    Thanks
    65
    Thanked 2,725 Times in 2,675 Posts

    Default Re: It does not return data as it should in the cycle

    I do not see that you have made the changes I suggested. Please make those changes and the problem should be fixed.

    Here is a start:
    		for (int  spinelliIndex = 0; spinelliIndex < spinelli.getListCellid().size() ; spinelliIndex++) {
    			for (int veicoloIndex = 0; veicoloIndex < veicoloDb.getListCellId().size() ; veicoloIndex++) {

    My suggestion was only for the nested for loops shown above.
    If you don't understand my answer, don't ignore it, ask a question.

  11. #11
    Member
    Join Date
    Jun 2017
    Posts
    46
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: It does not return data as it should in the cycle

    // Se la Targa veicolo sono uguali Aggiungi ID nella Nuova colonna
    		for (spinelliIndex = 0; spinelliIndex < spinelli.getListCellveicoli_id().size(); spinelliIndex++) {
    			for (veicoloIndex = 0; veicoloIndex < veicoloDb.getListCellId().size(); veicoloIndex++) {
    				if (spinelli.getSpinelliTarga().get(spinelliIndex).equals(veicoloDb.getVeicoloTarga().get(veicoloIndex))) {
    					System.out.println(
    							spinelli.getSpinelliTarga().get(spinelliIndex) + " =  " + veicoloDb.getVeicoloTarga().get(veicoloIndex));

    print:
    BP377GT = BP377GT
    OK
    BP377GT = BP377GT
    OK
    BP377GT = BP377GT
    OK
    BP377GT = BP377GT
    OK
    BP377GT = BP377GT
    OK

    does not work

  12. #12
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,162
    Thanks
    65
    Thanked 2,725 Times in 2,675 Posts

    Default Re: It does not return data as it should in the cycle

    does not work
    Please explain what that means.
    If you don't understand my answer, don't ignore it, ask a question.

  13. #13
    Member
    Join Date
    Jun 2017
    Posts
    46
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: It does not return data as it should in the cycle

    I'll explain the press:

    Targa == Targa

    That the first plate corresponds to spinelli.getSpinelliTarga (). Get (spinelliIndex)

    That the second plate corresponds

    veicoloDb.getVeicoloTarga (). get (veicoloIndex)

    Then I noticed
    public ArrayList <String> getVeicoli_id () {
    return Vehicles_id;
    }

    The list is empty

    which recalls

    public ArrayList <String> getListCellveicoli_id () {
    for (int rowIndex = 1; rowIndex <281; rowIndex ++) {
    currentRow = dataTypeSheet.getRow (rowIndex);
    cell_veicoli_id = currentRow.getCell (27); // Cell AB
    veicoli_id.add (cell_veicoli_id.getStringCellValue (). toString ());
    }
    return Vehicles_id;
    }

    when I recall the method again by indexing getVeicoli_id (), it appears EMPTY, how come?
    No restitusce anything
    Since the list is populated with
    veicoli_id.add (cell_veicoli_id.getStringCellValue (). toString ());

    I don't know how to solve it, I need help.

    for (spinelliIndex = 0; spinelliIndex < spinelli.getVeicoli_id().size(); spinelliIndex++) {
    			for (veicoloIndex = 0; veicoloIndex < veicoloDb.getVeicoloId().size(); veicoloIndex++) {
    				if (spinelli.getSpinelliTarga().get(spinelliIndex).equals(veicoloDb.getVeicoloTarga().get(veicoloIndex))) {
    					System.out.println(
    							spinelli.getSpinelliTarga().get(spinelliIndex) + " =  " + veicoloDb.getVeicoloTarga().get(veicoloIndex));

  14. #14
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,162
    Thanks
    65
    Thanked 2,725 Times in 2,675 Posts

    Default Re: It does not return data as it should in the cycle

    The list is empty
    Is that the correct value? Or should the list have entries?

    This method is confusing:
    public ArrayList <String> getListCellveicoli_id () {
       for (int rowIndex = 1; rowIndex <281; rowIndex ++) {
          currentRow = dataTypeSheet.getRow (rowIndex);
          cell_veicoli_id = currentRow.getCell (27); // Cell AB
          veicoli_id.add (cell_veicoli_id.getStringCellValue (). toString ());
       }
       return Vehicles_id;
    }
    Where is veicoli_id defined? Why does it add values to it ? Normal getXXX methods do not change variables. The code that changes veicoli_id should be in its own method.
    Why does it return Vehicles_id? That is the same value returned by getVeicoli_id.

    It is impossible to see the problem when you can only see small parts of the program.
    If you don't understand my answer, don't ignore it, ask a question.

  15. #15
    Member
    Join Date
    Jun 2017
    Posts
    46
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: It does not return data as it should in the cycle

    public ArrayList<String> getVeicoli_id() {
    		for (int rowIndex = 1; rowIndex < 281; rowIndex++) {
    			currentRow = dataTypeSheet.getRow(rowIndex);
    			cell_veicoli_id = currentRow.getCell(27); // Cella AB
    			veicoli_id.add(cell_veicoli_id.getStringCellValue().toString());
    		}
    		return veicoli_id;
    	}

    I did it this way, but the result is always the same.
    There are no other alternatives, the list must necessarily be popular to fill in the values ​​in the list.

    How can I implement the method?

    thank you so much


    Can you help me code the system, since I am a beginner?

  16. #16
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,162
    Thanks
    65
    Thanked 2,725 Times in 2,675 Posts

    Default Re: It does not return data as it should in the cycle

    The get method should NOT add values to list. There should be a separate method for that.
            public ArrayList<String> getVeicoli_id() {
    		return veicoli_id;
    	}
     
            public void fillVeicoli_id() {
    		for (int rowIndex = 1; rowIndex < 281; rowIndex++) {
    			currentRow = dataTypeSheet.getRow(rowIndex);
    			cell_veicoli_id = currentRow.getCell(27); // Cella AB
    			veicoli_id.add(cell_veicoli_id.getStringCellValue().toString());
    		}
     
          }
    If you don't understand my answer, don't ignore it, ask a question.

  17. #17
    Member
    Join Date
    Jun 2017
    Posts
    46
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: It does not return data as it should in the cycle

    now I try and let you know. thank you

    --- Update ---

    Thank you that you made me understand the problem a lot, it works, slowly I go ahead with the project, if I have other problems I create a new post

    thanks a lot

  18. #18
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,162
    Thanks
    65
    Thanked 2,725 Times in 2,675 Posts

    Default Re: It does not return data as it should in the cycle

    I'm glad you have made some progress. Do start another thread if you have more problems.
    If you don't understand my answer, don't ignore it, ask a question.

  19. #19
    Member
    Join Date
    Jun 2017
    Posts
    46
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: It does not return data as it should in the cycle

    Another thing is sorry again, in the first sheet in Excel I entered an extra id, instead in the second sheet in Excel I didn't insert it. For the negative ifs as I did in the code I don't print the negative

    }else if(!spinelli.getVeicoli_id().get(spinelliIndex).equals(veicoloDb.getVeicoloId().get(veicoloIndex))){
    					System.out.println(veicoloDb.getVeicoloId().get(veicoloIndex));
    				}


    I tried to insert an extra id on the first sheet but on the second sheet I didn't enter it, but the print doesn't come out

  20. #20
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,162
    Thanks
    65
    Thanked 2,725 Times in 2,675 Posts

    Default Re: It does not return data as it should in the cycle

    the print doesn't come out
    Can you give a short example of what the two lists look like and what you want printed when the code executes?

    Do want the code to print a message every time the the items in the two lists are not equal? That will make for a lot of print outs.
    If you don't understand my answer, don't ignore it, ask a question.

  21. #21
    Member
    Join Date
    Jun 2017
    Posts
    46
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: It does not return data as it should in the cycle

    Exactly, if the customer code is not present in the list, a message must be sent out. Come on can I implement in this case?

  22. #22
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,162
    Thanks
    65
    Thanked 2,725 Times in 2,675 Posts

    Default Re: It does not return data as it should in the cycle

    Can you give a short example of what the two lists look like
    and what you want printed when the code executes with those two short lists?

    I can not test the code without the full source, so I have to ask you to do the testing and post here the results. Without the print out, I can not help you.
    If you don't understand my answer, don't ignore it, ask a question.

  23. #23
    Member
    Join Date
    Jun 2017
    Posts
    46
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: It does not return data as it should in the cycle

    if the plaque is not found either in joints or in vehicles, print the plaque that is not the same or does not exist in the list

    for (spinelliIndex = 0; spinelliIndex < spinelli.getVeicoli_id().size(); spinelliIndex++) {
    			for (veicoloIndex = 0; veicoloIndex < veicoloDb.getVeicoloId().size(); veicoloIndex++) {
    				if (spinelli.getVeicoli_targa().get(spinelliIndex).equals(veicoloDb.getTarga().get(veicoloIndex))) {
     
    					System.out.println(spinelli.getVeicoli_targa().get(spinelliIndex) + " = "
    							+ veicoloDb.getTarga().get(veicoloIndex) + " --> "
    							+ spinelli.getVeicoli_id().get(spinelliIndex) + " --> "
    							+ veicoloDb.getVeicoloId().get(veicoloIndex));
     
    					// Scrivi nella riga i
    					row = sheet.getRow(spinelliIndex);
     
    					// Scrivi nella colonna AC indice 28
    					cell = row.createCell(28);
     
    					// Scrivi il ciclo in tutte le righe nella colonna AC indice 28
    					sheet.getRow(spinelliIndex).createCell(28)
    							.setCellValue(spinelli.getVeicoli_id().get(spinelliIndex));
     
    					FileOutputStream fos = new FileOutputStream(filePath);
     
    					// Scrivi nel file
    					wb.write(fos);
     
    					// Chiudi il file
    					fos.close();
     
    				} else if (spinelli.getVeicoli_targa().get(spinelliIndex) != veicoloDb.getTarga().get(veicoloIndex) || !(spinelli.getVeicoli_targa().get(spinelliIndex) != veicoloDb.getTarga().get(veicoloIndex))) {
    					System.out.println( "else:" + spinelli.getVeicoli_targa().get(spinelliIndex) + " = "
    							+ veicoloDb.getTarga().get(veicoloIndex) + " --> "
    							+ spinelli.getVeicoli_id().get(spinelliIndex) + " --> "
    							+ veicoloDb.getVeicoloId().get(veicoloIndex));
    				}
     
    			}
     
    		}

    This is what I print when I do, but in the part of ELSE, like that, it doesn't convince me

    else:FL962WE = EP342EL --> 25868 --> 25652
    else:FL962WE = EP343EL --> 25868 --> 25653
    else:FL962WE = EP478EL --> 25868 --> 25654
    else:FL962WE = EP479EL --> 25868 --> 25655
    else:FL962WE = EP480EL --> 25868 --> 25656
    else:FL962WE = EP481EL --> 25868 --> 25657
    else:FL962WE = EP482EL --> 25868 --> 25658


    In addition, I must print both the license plates and the license plates that are not the same or that the license plate is not present in the list of joints or in the vehicle list


    thank you

  24. #24
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,162
    Thanks
    65
    Thanked 2,725 Times in 2,675 Posts

    Default Re: It does not return data as it should in the cycle

    I am sorry, I do not see where you added any comments to the print out showing where it is wrong
    and describing what the correct output should be.
    What is wrong with the program's output?
    What should the correct output look like?

    For example it the two lists have this contents shown in these two columns of numbers:
    1 5
    2 6
    3 7
    4 8
    What should the print out look like?
    Should there be 16 else: lines printed? One for each of the 16 comparisons.
    else: 1 5
    else: 1 6
    ...
    else: 4 8
    If you don't understand my answer, don't ignore it, ask a question.

  25. #25
    Member
    Join Date
    Jun 2017
    Posts
    46
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: It does not return data as it should in the cycle

    If the license plates are the same in the IF code, the print exits in this way.

    BP377GT = BP377GT --> 25610 --> 25610
    BV469PE = BV469PE --> 25611 --> 25611
    ........
    When I insert the other ELSE instruction ...... as you see in the code

    the print must appear as follows:

    The license plate of the vehicleDb.getTarga (). Get (vehicleIndex) was not found in the list or spinelli.getVeicoli_targa (). Get (spinelliIndex) the license plate was not found in the list

Page 1 of 2 12 LastLast

Similar Threads

  1. String subdivision and data return problem
    By glprobot in forum Java Theory & Questions
    Replies: 1
    Last Post: May 31st, 2019, 06:29 AM
  2. Two ArrayLists don't cycle thru formula
    By CiscoKid in forum Loops & Control Statements
    Replies: 1
    Last Post: January 2nd, 2019, 06:41 AM
  3. Replies: 8
    Last Post: December 4th, 2012, 04:58 AM
  4. [SOLVED] Problem accessing specific data in an array and getting it to return properly
    By Universalsoldja in forum Collections and Generics
    Replies: 3
    Last Post: February 4th, 2010, 04:26 PM