94
Java Convert String to Object
We can convert String to Object in java with assignment operator. Each class is internally a child class of Object class. So you can assign string to Object directly.
You can also convert String to Class type object using Class.forName() method.
Java String to Object Example
Let’s see the simple code to convert String to Object in java.
Let’s see the simple code to convert String to Object in java.
Output:
hello
Java String to Class object Example
Let's see the simple code to convert String to Class object in java using Class.forName() method. The Class.forName() method returns the instance of Class class which can be used to get the metadata of any class.
Output:
Class name: java.lang.String Super class name: java.lang.Object
Next TopicJava Object to String