Writing and appending

Report a typo

What will be contained in the file MyFile.txt after the execution of this program?

import java.io.File

fun main() {
    val fileName = "MyFile.txt"
    val myFile = File(fileName)

    myFile.writeText("1")
    repeat(2) {
        myFile.appendText("2")
    }
}
Enter a number
___

Create a free account to access the full topic