why am i getting the error that string cannot be converted to int

29 views Asked by At
import java.util.Scanner;
class student1
{
String name;
static Scanner s1=new Scanner(System.in);


void set()
{
name=s1.next();
}
}
class demo
{
public static void main(String args[])
{
student1 s[]=new student1[student1.s1.next()];
for(int i=0;i<s.length;i++)
{
s[i]=new student1();
s[i].set();
}
}
}


I tried running this code and i am getting the error : E:\java-practice>javac student1.java student1.java:17: error: incompatible types: String cannot be converted to int student1 s[]=new student1[student1.s1.next()]; ^

0

There are 0 answers