Since arrays are 0-indexed in Java, you should change your loop initialization variable j to start at 0.
Change:
for (int j = 1; j < n; j++) {
to
for (int j = 0; j < n; j++) {
Also, it seems you want a method to do the conversion, not a class so you should remove this from your method signature and put void since you aren't returning anything from the method.
Change:
public static class convert(String[] lines)
To:
public static void convert(String[] lines)
Also, you should use a different variable to iterate through the string array to make things more cleaner. Since you are trying to use j, you can do that to. Instead of initializing j to 1, you initialize it to 0 as I've said and use j+1 as the index for accessing the lines array.
Here is how your code could look like:
public static void convert(String[] lines)
int n = Integer.parseInt(lines[0]);
int[][] matrix = new int[n][n];
for (int j = 0, k = 1; j < n; j++) {
String[] currentLine = lines[j + 1].split(" ");
for (int i = 0; i < currentLine.length; i++) {
matrix[j][i] = Integer.parseInt(currentLine[i]);
}
}
}
j = 1--->j = 0, other than that it's all good.