https://kotlinlang.org logo
#getting-started
Title
# getting-started
c

Colton Idle

11/23/2020, 1:41 AM
All classes in java extend Object. All classes in Kotlin extend Any. Why is that?
n

nanodeath

11/23/2020, 1:43 AM
maybe to avoid confusion with
object
. maybe also because Kotlin is multiplatform and not every platform has
Object
r

Ruckus

11/23/2020, 4:20 AM
Also, something like
List<Any>
is a bit more intuitive than
List<Object>
imao.
2
s

Shawn

11/26/2020, 1:50 AM
I interpreted this question to mean “why do all classes in Kotlin and Java inherit from a shared superclass”, and I found these interesting StackOverflow threads pertaining to C# https://stackoverflow.com/questions/1583482/why-does-every-class-in-net-inherit-from-object/1583524#1583524 https://softwareengineering.stackexchange.com/questions/157450/why-all-classes-in-net-globally-inherits-from-object-class
n

nanodeath

11/26/2020, 2:15 AM
oh. I thought the question was why don't Kotlin classes extend the same class as Java classes.
s

Shawn

11/26/2020, 2:31 AM
That very well might’ve been the original intent 😅 I just thought y’all might still be interested in those threads
The fact that
java.lang.Object
isn’t cross-platform is probably the biggest reason though
n

nanodeath

11/26/2020, 2:55 AM
maybe, but I'd be kinda impressed they were thinking that far ahead with Kotlin 1.0