Bom dia,
Por favor, como exibo os números positivos … no código abaixo eu consigo mostrar todos e logo depois o negativos… minha intenção é mostra-los separados…
Onde estou errando???
Obrigado
import javax.swing.*;
public class Vetor {
public static void main(String args[]) {
int A[] = new int[4];
int B[] = new int[4];
String strA = "", strB = "";
int i, j=0;
for(i=0; i<A.length; i++)
{
A[i] = Integer.parseInt(
JOptionPane.showInputDialog("Entre com o "+(i+1)+"º número:"));
if(A[i] < 0)
{
B[j] = A[i];
j++;
}
}
for(i=0; i<A.length; i++)
{
strA += A[i] + ", ";
}
JOptionPane.showMessageDialog(null, "A=" + strA);
for(i=0; i<j; i++)
{
strB += B[i] + ", ";
}
JOptionPane.showMessageDialog(null, "B=" + strB);
}
}