خرید بک لینک

Vote count: 0

Here is how the text file is formatted

8   5
String1 String2 String3

I want the 8 and 5 to be the respective rows and columns and then add the strings into the array so I have

    File f4 = new File(s);
    Scaer in=new Scaer(f4);

    int i = 0;
    int rows = 0;
    int columns = 0;
    while (in.hasNextInt())
    {
        rows = in.nextInt();
        columns = in.nextInt();         
    }

    String[][] data = new String[rows][columns];

    for (int t = 0;i < data.length; i++) {
        for (int j = 0; j<data[i].length; j++)
        {
            data[t][j] = in.next();
        }
    }
    retu data;

However, data is just filled with null strings and the last row of the text file why?

asked 4 mins ago

برچسب: نویسنده: استخدام کار تاريخ: چهارشنبه 1 ارديبهشت 1395 ساعت: 11:32

صفحه بندی