Skip to content
Advertisement

error: incompatible types: String[] cannot be converted to String

I tried taking input of a 6 by 6 matrix in java using the string split function when the string is input in the following way, and to print the matrix.

JavaScript

The output that I get is

JavaScript

my code:

JavaScript

pls, suggest how I can overcome this error

Advertisement

Answer

When we call split function of String return the String[]. So c[j] (which is of type String) can’t be equal to String[].

Below code should be replaced as:

JavaScript
Advertisement