Skip to content

Instantly share code, notes, and snippets.

@memish
Created October 8, 2018 15:08
Show Gist options
  • Save memish/a17c4fb0d50a794e1bd7da12b969da42 to your computer and use it in GitHub Desktop.
Save memish/a17c4fb0d50a794e1bd7da12b969da42 to your computer and use it in GitHub Desktop.
public class TwoDArray
{
public static void main(String args[])
{
// int[][] sales = new int[4][6];//row column
//OR
//q1, q2,q3,q4
int[][] sales = { {2,3,4,5},//2014
{7,8,9,10},//2015
{12,14,15,16} };//2016
/* */
// System.out.println(sales.length);//amount of rows
// System.out.println(sales[0].length);//amount of columns
// sales [0][0] = 6;//set quarter 1, year 2014 to 6
System.out.println( sales [0][sales[0].length-1]);//retrieve sales from Q4 year 2014 -- sales[0].length-1
for (int row = 0; row < sales.length; row++) {
for (int col = 0; col < sales[0].length; col++) {
// System.out.print( sales[row][col] + " ");
if(sales[row][col]==10)
System.out.print( row + " " + col);
}
System.out.println( );
}
/* */
}}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment