0
package mobile;
import java.util.*;
/**
 *
 * @author user
 */
public class Mobile {

    /**
     * @param args the command line arguments
     */


public static void main(String[] args) {

    int[][] data = new int[10][10];

    data = timesTable(10,10);
    Scanner scan = new Scanner(System.in);

    System.out.print("Enter Row:");
    int row2 = scan.nextInt();
    System.out.println("");
    System.out.print("Enter Column:");
    int column2 = scan.nextInt();

    for (int row = 0; row < data.length ; row++)
    {
        for (int column = 0; column < data[row].length; column++)
        {
            System.out.printf("%2d ",data[row][column]);
        }
        System.out.println();

    }
}

public static int[][] timesTable(int r, int c)
{
     int [][] yes = new int[r][c];

    for (int row = 0; row < yes.length ; row++)
    {
        for (int column = 0; column < yes[row].length; column++)
        {
            yes[row][column] = (row+1)*(column+1);
        }

    }
    return yes;
}

}

can some one tell me how i can call the data's of row2 and column2 and insert them onto "int [][] yes = new int[r][c];" replacing the value of r and c respectively.
`

2
Contributors
3
Replies
15
Views
2 Years
Discussion Span
Last Post by stultuske
0

so .. basically, you need to know how to call a method ?

int[][] data2 = new int[row2][column2];

make sure to add this line after you've initialized both values.

0

im not really good at java so i mostly use this. but is doest seem to work since im using a static variable and in not really sure how to use getter and setter.

0

you can't use the this keyword here, because the this keyword points to the current instance, while you don't have an actual instance.

also: static members shouldn't be called through an instance, but through the class.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.