在ArrayList INSIDE Stack中搜索一个元素

时间:2018-06-12 02:30:10

标签: java arraylist stack

我不知道这是否是最佳的,但我必须使用堆栈进行考试练习,我决定使用包含ArrayList的Stack,其中包含包含字符串类型变量的ArrayLists;

后来我想找一个元素,一个ID。这是我被困的地方。 这就是我为这个搜索功能编写的代码:

  private void btn_actualizarActionPerformed(java.awt.event.ActionEvent evt) {                                               
    // TODO add your handling code here:
    //Busqueda:
    String criterio;
    Stack <ArrayList<ArrayList<String>>> pila_registro=new Stack <>(); //This is outside this class,  added it here just so you know how the stack works
    criterio=JOptionPane.showInputDialog("Ingrese el carne de seguro del paciente por buscar:");
    int index=pila_registro.search(criterio);
    if (index!= -1) {
        JOptionPane.showMessageDialog(null,"Paciente encontrado!");
        System.out.print(index);
    }
    else{
        JOptionPane.showMessageDialog(null, "Paciente no encontrado!");
        System.out.println(index);
    }
}                                              

0 个答案:

没有答案