boa noite pessoa sou novo aki e no mundo da programação, estou tentando fazer um sistema para dar um select no banco, ate hai ja esta tudo certomporem estou com uma duvida que não sei como resolver preciso pegar um valor que esta alocado em um posição do array não sei como posso fazer isso, vou postar o codgo
public class tela extends javax.swing.JFrame {
private ArrayList<String> VEI_ID = new ArrayList<String>();
private ArrayList<String> VEI_PLACA = new ArrayList<String>();
/** Creates new form tela */
public tela() {
initComponents();
}
/** This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
jButton1 = new javax.swing.JButton();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
jButton1.setText("jButton1");
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});
org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(layout.createSequentialGroup()
.add(129, 129, 129)
.add(jButton1)
.addContainerGap(174, Short.MAX_VALUE))
);
layout.setVerticalGroup(
layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(layout.createSequentialGroup()
.add(99, 99, 99)
.add(jButton1)
.addContainerGap(172, Short.MAX_VALUE))
);
pack();
}// </editor-fold>
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
Statement stmt = Conexao.get();
String sql = "SELECT udl.VEI_ID, udl.UDL_DH, v.CLI_ID, v.VEI_COD, v.VEI_PLC FROM arenateste.ult_dado_lido AS udl INNER JOIN veiculo AS v ON v.VEI_ID = udl.VEI_ID AND udl.UDL_DH < (NOW()- INTERVAL 5 DAY) ORDER BY udl.UDL_DH";
try {
ResultSet rs = stmt.executeQuery(sql);
while (rs.next()) {
this.VEI_ID.add(rs.getString("VEI_PLC"));
System.out.println(VEI_ID);// [b]aki estou tentando mostra o que tem no array (vou posta o resultado embaixo) [/b]
}
} catch (SQLException ex) {
Logger.getLogger(tela.class.getName()).log(Level.SEVERE, null, ex);
}
}
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new tela().setVisible(true);
}
});
}
// Variables declaration - do not modify
private javax.swing.JButton jButton1;
// End of variables declaration
}
Resultado
[]
[, ]
[, , ]
[, , , ]
[, , , , NNK-1483]
[, , , , NNK-1483, MYL-4213]
[, , , , NNK-1483, MYL-4213, MYP - 4828]
[, , , , NNK-1483, MYL-4213, MYP - 4828, HUL - 6158]
[, , , , NNK-1483, MYL-4213, MYP - 4828, HUL - 6158, MYP-5907]
[, , , , NNK-1483, MYL-4213, MYP - 4828, HUL - 6158, MYP-5907, MYL-6369]
[, , , , NNK-1483, MYL-4213, MYP - 4828, HUL - 6158, MYP-5907, MYL-6369, NNM-4487]
[, , , , NNK-1483, MYL-4213, MYP - 4828, HUL - 6158, MYP-5907, MYL-6369, NNM-4487, ]
[, , , , NNK-1483, MYL-4213, MYP - 4828, HUL - 6158, MYP-5907, MYL-6369, NNM-4487, , MZC-0340]
[, , , , NNK-1483, MYL-4213, MYP - 4828, HUL - 6158, MYP-5907, MYL-6369, NNM-4487, , MZC-0340, MXM-9575]
[, , , , NNK-1483, MYL-4213, MYP - 4828, HUL - 6158, MYP-5907, MYL-6369, NNM-4487, , MZC-0340, MXM-9575, MYN-0681]
[, , , , NNK-1483, MYL-4213, MYP - 4828, HUL - 6158, MYP-5907, MYL-6369, NNM-4487, , MZC-0340, MXM-9575, MYN-0681, MXP-1877]
[, , , , NNK-1483, MYL-4213, MYP - 4828, HUL - 6158, MYP-5907, MYL-6369, NNM-4487, , MZC-0340, MXM-9575, MYN-0681, MXP-1877, MZE-7908]
[, , , , NNK-1483, MYL-4213, MYP - 4828, HUL - 6158, MYP-5907, MYL-6369, NNM-4487, , MZC-0340, MXM-9575, MYN-0681, MXP-1877, MZE-7908, MZE-7918]
[, , , , NNK-1483, MYL-4213, MYP - 4828, HUL - 6158, MYP-5907, MYL-6369, NNM-4487, , MZC-0340, MXM-9575, MYN-0681, MXP-1877, MZE-7908, MZE-7918, HUQ-9112]
[, , , , NNK-1483, MYL-4213, MYP - 4828, HUL - 6158, MYP-5907, MYL-6369, NNM-4487, , MZC-0340, MXM-9575, MYN-0681, MXP-1877, MZE-7908, MZE-7918, HUQ-9112, MXU-4388]
[, , , , NNK-1483, MYL-4213, MYP - 4828, HUL - 6158, MYP-5907, MYL-6369, NNM-4487, , MZC-0340, MXM-9575, MYN-0681, MXP-1877, MZE-7908, MZE-7918, HUQ-9112,
[