We are about to switch to a new forum software. Until then we have removed the registration on this forum.
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;
//conversion
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;
break;
}else{
continue;
}
}
}
I get an error on line 20 "cannot convert from int to String"
Answers
https://Processing.org/reference/strconvert_.html
https://Processing.org/reference/String_equals_.html
x.equals(y)
x = "" + j;