JAVA 提示有错,不知道怎么改

2025-04-19 16:03:49
推荐回答(2个)
回答1:

// 实现了将一行语法字符串分解开并存入对应的3维数组位置里

import java.io.*;
import java.util.ArrayList;
import java.util.Iterator;

public class GraduateResearch1_4 {
// static ArrayList strings = new ArrayList();
public static void main(String args[]) {
String SSS1 = new String("S=NP+VP");
String SSS2 = new String("new=新的");
fetchDictionary(SSS1);
fetchDictionary(SSS2);
}

public static void fetchDictionary(String s) {
String[][][] s1 = new String[10][2][2];
String[][] s2 = new String[10][2];

if (s.indexOf("=") != -1) {
if (s.indexOf("+") != -1) {
int i = s.indexOf("=");
int j = s.indexOf("+");
s1[0][0][0] = s.substring(0, i);
s1[0][1][0] = s.substring(i + 1, j);
s1[0][0][1] = s.substring(j + 1);
System.out.println(s1[0][0][0]);
System.out.println(s1[0][1][0]);
System.out.println(s1[0][0][1]);
} else {
int i = s.indexOf("=");
s2[0][0] = s.substring(0, i);
s2[0][1] = s.substring(i + 1);
}
} else
System.out.println("字典中有不含等号的语法");
}

}

回答2:

下次提问t贴报错信息