Difference between class and object in Kotlin: when to use the object keyword?
Hello! I just started learning Kotlin after Java and got confused about the object keyword. In Java we use new to create instances, and class is just a template. But in Kotlin I see that object is used everywhere: for declaring singletons, for creating anonymous classes, and even as a companion object inside a class.
Here's an example that confuses me:
```kotlin
// Is this a class?
class MyClass {
fun doSomething() {
println("Hello from class")
}
}
// And what is this? Also a class?
object MyObject {
fun doSomething() {
println("Hello from object")
}
}
// And how to use it?
fun main() {
val instance = MyClass() // Ok, creating a class instance
MyObject.doSomething() // But here without new? Why?
}
```
Please explain in