EDIT : [Schoolwork Assignment]

So, I want to encode, with only 0 and 1, words.

**0 = word not present  

1 = word present**

My dictionary correspond to :

```
String[] dictionary = {"Hello", "I", "am", "Lukas", "and", "Jonas", "play", "football"};

```

For example : If I encode these words...

```
String[] listOfWords = {"Hello", "play" "football"};

```

I must have the following array :

```
int[] wordsEncode = {1,0,0,0,0,0,1,1};

```

You can see that "Hello" is present, "I" "am" "Lukas" "and" "Jonas" are not present. Finally, "play" and "football" are present.  

**We must preserve the order of dictionary and that is my problem in my code.  

I don't really know how to fix that problem (using a second for loop ?) ?**  

I think **wordEncode[i]** is my **error**, but how to fix that ?

Here is my code :

```
class Dictionary {

    /**
     * Array words Dictionary
     */
    String[] dictionary;

    /**
     * Maximum of words MAX_WORDS
     */
    final int MAX_WORDS = 50;

    /**
     * Number of words in the dictionary
     */
    int numberWordsDictionary;

    /**
     * Constructor
     */
    Dictionary() {
        dictionary = new String[MAX_WORDS];
        numberWordsDictionary = 0;
    }

int[] encoder(String[] listOfWords) {
    int[] wordsEncode = new int[numberWordsDictionary];

    StringBuilder builder = new StringBuilder();
    for(String word : dictionary) {
        builder.append(word);
    }
    String dictionaryString = builder.toString();     

    for(int i = 0; i < listOfWords.length; i++) {
        if(dictionaryString.contains(listOfWords[i])) {
            wordsEncode[i] = 1;
        } else {
            wordsEncode[i] = 0;
        }
    }
    return wordsEncode;
}

}

```

Sorry about indentation (not same as my Java IDE) :(  

Thanks !