Need help in constructing a 2 dimensionla array?

Need help in constructing a 2 dimensionla array?

Construct a 2 dimensional array that for each entry in the array, display the index of the first dimension data entered, the second dimension's value of the data entered, and the first dimension's value on a single line separated by : (colon).

here is what i got but i dont know what im missing thanks in advance.

public class twoDimension{ public static void main(String[] args) { int[][] a2 = new int[][]; for (int i=0; i

View Answers

July 11, 2012 at 11:40 AM

Here is an example of generating two-dimensional array.

import java.util.*;

public class twoDimension{
    public static void main(String[] args) { 
        Scanner input=new Scanner(System.in);
        System.out.print("Enter value of i: ");
        int a=input.nextInt();

        System.out.print("Enter value of j: ");
        int b=input.nextInt();

        int[][] a2 = new int[a][b];
        System.out.println("Enter elements of your choice: ");
        for(int i=0 ; i < a2.length ; i++){
          for(int j=0 ; j < a2[i].length ; j++){
          a2[i][j] = input.nextInt();
        }
        }
        for(int i=0 ; i < a2.length ; i++){
            System.out.println();
            for(int j=0 ; j < a2[i].length ; j++){
                System.out.print(a2[i][j]+" ");
            }
        }
    }
}









Related Tutorials/Questions & Answers:
Need help in constructing a 2 dimensionla array?
Need help in constructing bubble sort
Advertisements
guys,, need help,, in java programing,, arrays
How to Append Arrays in PHP
Need help to create Struts 2 MySQL based HRMS application.
Need help with this!
Printing 2 arrays
Need help
Need help
Need help
arrays help - Java Beginners
arrays part 2 - Java Beginners
how to compare 2 arrays using java?
need help with program
Need Help on JMS - JMS
Need help with nested queries
need help please
Need Help in Java programming
need help to create applet
need help with program
Need help on JAVA JSP
Friends need a help on ruby..
Need some help urgently
help me 2
need help - Java Beginners
hello there i need help
Need help with console program?
Need Help With This Scenario
Need Help With This Scenario
Need Help - Java Beginners
i need a help in this please
Need Help on the script
seriously need help....
Need help - Java Beginners
Need help with my project
Need help in java programming
need help...................please
need help with a program - Java Beginners
I have need to help
need help - Swing AWT
Need urgent help with C++ errors!
need help with a program - Java Beginners
Need help on mySQL 5 - SQL
need someone to do/help with code
Arrays
Java Programming Need Help ASAP
Need *Help fixing this - Java Beginners
Need help writing a console program
PLZ Need some help JAVA...HELP !!
i need help - Development process

Ads