'How to observe two lists and compare them?

I am making an Android App, which generates a random four-digit number and must check input in EditText from a user and compare it with a random list. Can u help me with observing two lists? Can not figure out how to make it myself.

GameViewModel class and method which should observe Lists (didn`t work):

fun checkLists(enterList: List<Int?>, randomList: List<Int>) {
        if (enterList == randomList) {
            onGameOver(true)
        }
    }

GameFragment binding and button listener:

launchUI {
            val listInTextField =
                binding.outlinedEditField.text.toString().split("").map { it.toIntOrNull() }

            binding.listTextView.text = getString(
                R.string.list_num,
                randomList.toString().replace("[", "").replace("]", "")
            )

            binding.run {
                enterButton.setOnClickListener {
                    viewModel.checkLists(listInTextField, randomList)
                }
            }
        }

The problem is that i need not just compare hole list and value, but every number in it and it`s position.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source