Flexible nature of java.lang.Object
We all love the mechanism of python, where we don’t have to bother about the data types of the variables. Interestingly we have one class in Java too, which is pretty similar! It’s java.lang.Object.
java.lang.Character java.lang.Integer java.lang.String java.lang.Double java.lang.Boolean
Such behavior can be attributed to the fact that the Object class is a superclass to all other classes. Hence, a reference variable of type Object can be practically used to reference objects of any class. So, we could also assign y = new InputStreamReader(System.in) in the above code.
This article is contributed by Ashutosh Singh. If you like GeeksforGeeks and would like to contribute, you can also write an article and mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks. Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.