简体   繁体   English

需要数组但找到字符串错误

[英]Array Required But String Found error

for(int x=0;x<n;x++){
BT[x]=0;
WT[x]=0;
JB[x]=0; 
s1[x]=" ";
s2[x]=" ";
}  

I cannot initialize the string s1 and s2 it gives me error Array Required But String Found error. 我无法初始化字符串s1和s2,这给了我错误Array Required but String Found错误。

int n,BT[],WT[],JB[];
String s1[];
String s2[];
String s=JOptionPane.showInputDialog("Enter no of process");
//System.out.println("Enter no of process");
n=Integer.parseInt(s);//sc.nextInt();
BT=new int[n+1];
WT=new int[n+1];
JB=new int[n+1];
s1=new String[n+1];
s2=new String[n+1];

This is the code that sets the array size of s1 and s2 这是设置s1和s2的数组大小的代码

Fixed it! 修复! the strings were not passed to the class below. 字符串没有传递给下面的类。 dumb mistake 愚蠢的错误

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM