Replacing characters of string array with numbers

edited September 2017 in Questions about Code

So I have 2 .txt files, one (test.txt) contains a quote and the other (data.txt) contains all of the characters that can possibly occur in it. Each one has been formatted so that each character is on a new line and each string in the array contains a single character. What I need to do is convert each character in test.txt into an integer that corresponds with the index of the identical character in data.txt. For example: a=0, b=1, c=2...

//arrays for .txt files
String[] data;
String[] test;
//stores length of total characters in data.txt
int num;
//stores length of total characters in test.txt
int total;

data = loadStrings("data.txt");
num = data.length;
test = loadStrings("test.txt");
total = test.length;

for (int i = 0; i < total; i++) {
  String x = test[i];
  for (int j = 0; j < num; j++){
    String y = data[j];
    if(x == y){
        x = j;

I get an error on line 20 "cannot convert from int to String"

Sign In or Register to comment.