+ 1
Does String class extend Object even though its a final class?
I'm just trying to figure out the internal workings of valueOf() method because String class has this but it's not overridden 🤔 and slightly confused were the instance is comming from or dosent it matter because either way it's still an instance of String?
3 Respuestas
+ 3
Object is at the top of the hierarchy and the String class extends it. Final class can extend other classes but it itself cannot be subclassed.
The valueOf() in the String class is static so it doesn't allow overriding moreover you need to extend the class first to override a method which is not possible in this case.
+ 2
Avinesh ah yes I knew that i think I'm confusing my self with somthing else thanks for the refresh 😉