samedi 27 juin 2015

Printing whats inside the array

import java.io.*;
public class redtry4 {
    public static void main(String[]args)throws IOException{
        BufferedReader IN = new BufferedReader(new InputStreamReader(System.in));
        int[]numx = new int[10];
        System.out.println("Enter 10 different numbers:");
        for(int b=0; b<10; b++)
        {
            System.out.print("Number"+(b+1)+":");
            numx[b]=Integer.parseInt(IN.readLine());


        }
        System.out.print("Accepted numbers are:"+"\n");

    }
}

This is a working code. I wonder how would your print all the numbers youve inputed inside the array like for example:

Accepted numbers are: 1 2 3 4 5 6 7 8 9 12

and can i have ideas on how can i only put numbers that are not the same when inputed.

thanks!

Aucun commentaire:

Enregistrer un commentaire