Help in Java, I have problems printing an Array String []

0

Hello, I want to print a list of arrayList that has a document name, its address, its value and an array String [] of those who voted for that document but prints me with certain objects and not others. This is my main

package PackPiezas;

import java.util.ArrayList;
import java.util.Arrays;

public class EjecutorMain {

    public static void main(String [] args){

        ArrayList <Personas> listPersona=new ArrayList();
        String namePer []= {"javier", "jesus", "ramses", "sol", "antonieta",
                            "flor", "jorge", "mariangel","manuel", "marlyn",
                            "maria", "nenina", "diana", "yoser", "weber",
                            "jose andres", "simon", "rosimar", "andres", "carlos luis"};
        BusqArc p=new BusqArc();
        p.StartList();//Aqui creo la lista de documentos, solo obtiene documentos de una carpeta del equipo
        MetodosListCanc p1=new MetodosListCanc(p.listCanc);

        CrearPer(listPersona, namePer,p,p1);

        System.out.println("*********************************************************");

        MetodosListCanc.OrdXValue(p.listCanc);

        for(int i=0; i<p.listCanc.size();i++){
            MetodosListCanc.impObj(p.listCanc.get(i)); //Aqui mando a imprimir
        }
    }

    private static void CrearPer(ArrayList <Personas> listPersona, String [] namePer, BusqArc sp,MetodosListCanc pd){

        for(int i=0; i<20;i++){
            Personas sd=new Personas(namePer[i]);
            listPersona.add(sd);
        } 
        VotoPer(listPersona,sp,pd);// este metodo realiza una especie de votacion aleatoria
    }

    private static void VotoPer(ArrayList <Personas> lista, BusqArc sp, MetodosListCanc pd){
        int j=0;
        while(j<20){
            int i=0;
            while(i<3){
                int num=(int) (Math.random() * sp.listCanc.size()-1) + 0;
                if(!DocVot(lista.get(j).getNameArc(), (String) sp.listCanc.get(num).getName())){
                    pd.sumValue(num, lista.get(j));
                    i++;
                }
            }
            j++;
        }
    }

    private static boolean DocVot(String [] numArc, String arc){
        boolean existe=false;
        for(int i=0; i<3;i++){
            if(numArc[i]==arc){
                existe=true;
            }
        }
        return existe;
    }
}

Here is where I have the method

     package PackPiezas;

    import java.util.ArrayList;
    import java.util.Arrays;

    public class MetodosListCanc {


  ArrayList <InfCanc> list;

  public MetodosListCanc(ArrayList<InfCanc> list){
      this.list=list;
  }

public void sumValue(int i, Personas j){
    list.get(i).setVal(list.get(i).getVal()+1);
    String DDoc []=j.getNameArc();
    //System.out.println("1)"+Arrays.toString(DDoc));
    boolean ing=false;
    for(int h=0; h<3;h++){
        if(DDoc[h]==null && ing==false){
            DDoc[h]=(String) list.get(i).getName();
            ing=true;
        }
    }
    j.setNameArc(DDoc);

    boolean ingV=false;
    String VVot []=list.get(i).getVotantes();
    for(int h=0; h<20;h++){
        if(VVot[h]==null && ingV==false){
            VVot[h]=j.getName();
            ingV=true;
        }
    }
    list.get(i).setVotantes(VVot);
    //System.out.println(Arrays.toString(list.get(i).getVotantes())); Aqui comprobe que se este guardando el String [] en el objeto y si lo hace pero no entiendo sigue ocurriendo lo mismo
}

public static void OrdXValue(ArrayList <InfCanc> list){
    int tamA=list.size();
    int aux,j;
    for(int i=0;i<tamA;i++){
        j=i;
        aux=list.get(i).getVal();
        //System.out.println("valor de aux= "+aux+" Vuelta ="+i);
        InfCanc obAux=new InfCanc(list.get(i));
        while(j>0 && list.get(j-1)!=null && aux<list.get(j-1).getVal()){
            list.remove(j);
            list.add(j-1, obAux);
            j--;
        }
        //System.out.println("valor de j="+j);  
    }
}
public static void impObj(InfCanc i){
    System.out.println(i.getName());
    System.out.println(i.getLoc());
    System.out.println(i.getVal());
    System.out.println("Votantes: [");
    String sl []=i.getVotantes();
    for(int j=0; j<20;j++){
        System.out.print(sl[j]+", ");
    }
    System.out.println("]");
    System.out.println("------------");
}
/*public static void impObj(int i){
    System.out.println(list.get(i).getName());
    System.out.println(list.get(i).getLoc());
    System.out.println(list.get(i).getVal());
    System.out.println("Votantes: "+Arrays.toString(list.get(i).getVotantes()));
    System.out.println("------------");
}*/}

This is my exit, if you observe some you have your vote but you do not register who voted

doc.pdf
C:\Users\Javier Marín\Documents
2
Votantes: [
null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, ]
------------
Reglamento Trab de Grado Pregr junio 2016.pdf
C:\Users\Javier Marín\Documents
2
Votantes: [
null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, ]
------------
Trabajo de pasantias - Corfo.pdf
C:\Users\Javier Marín\Documents
2
Votantes: [
null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, ]
------------
Antecentes penales Apostillados - Jose Gregorio Silva Guedez.PDF
C:\Users\Javier Marín\Documents
3
Votantes: [
ramses, sol, nenina, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, ]
------------
Apostilla del titulo - Jose Gregorio Silva Guedez.PDF
C:\Users\Javier Marín\Documents
3
Votantes: [
antonieta, diana, simon, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, ]
------------
EJEMPLO INFORME DE PASANTIAS.pdf
C:\Users\Javier Marín\Documents
3
Votantes: [
antonieta, flor, rosimar, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, ]
------------
Trabajo de Pasantias - Corfo firmado.pdf
C:\Users\Javier Marín\Documents
3
Votantes: [
null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, ]
------------
escanear0001 (2).pdf
C:\Users\Javier Marín\Documents
4
Votantes: [
jorge, mariangel, marlyn, weber, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, ]
------------
escanear0001 (3).pdf
C:\Users\Javier Marín\Documents
4
Votantes: [
javier, weber, jose andres, carlos luis, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, ]
------------
escanear0001.pdf
C:\Users\Javier Marín\Documents
4
Votantes: [
null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, ]
------------
Foto - Jose Gregorio Silva Guedez.PDF
C:\Users\Javier Marín\Documents
4
Votantes: [
null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, ]
------------
normas_t_grado2016.pdf
C:\Users\Javier Marín\Documents
4
Votantes: [
null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, ]
------------
Partida de Nacimiento - Jose Gregorio Silva Guedez.PDF
C:\Users\Javier Marín\Documents
4 /*aca se muestra el numero de votos, y abajo debe mostrar quienes votaron*/
Votantes: [
null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, ]
------------
escanear0001 (4).pdf
C:\Users\Javier Marín\Documents
5
Votantes: [
jesus, ramses, mariangel, manuel, simon, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, ]
------------
Pasaporte - Jose Gregorio Silva Guedez.PDF
C:\Users\Javier Marín\Documents
5
Votantes: [
javier, nenina, weber, jose andres, andres, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, ]
------------

There are some documents where votes are not recorded and other documents where if the votes are recorded, I do not understand and try to do it in different ways, first send the list of arraylist, then send the object and then send only the position of the document that I want to print and even then it gives me the same result String [] leaves null and another if it goes out with their voters, any opinion would be helpful.

    
asked by Javier Marin 13.09.2018 в 22:32
source

0 answers