Home > Blockchain >  Print Array Input by User Java [closed]
Print Array Input by User Java [closed]

Time:09-23

Question is: How to print the array in these order?

Shirt # 1: [] Shirt # 2: [] so on

Below is the code.

        Scanner input = new Scanner(System.in);
        int sNumber = 4;
        // ang sNumber ay Shirt Number/Shirt Numbering
        String sSize,sColor,sBrand;
        
        String[][] shirt = new String[5][3];
        for (int counter = 0; counter <= sNumber; counter  ){
            System.out.println("Enter Shirt#"   (counter   1)   " Size: ");
            shirt[counter][0] = input.next();
            
            System.out.println("Enter Shirt#"   (counter   1)   " Color: ");
            shirt[counter][1] = input.next();
            
            System.out.println("Enter Shirt#"   (counter   1)   " Brand: ");
            shirt[counter][2] = input.next();
            
        }
        

CodePudding user response:

System.out.println(Arrays.deepToString(shirt)) should do the trick

  • Related