Java Convert String to ObjectWe 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 ExampleLet'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. Test it NowOutput: hello Java String to Class object ExampleLet'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. Test it NowOutput: Class name: java.lang.String Super class name: java.lang.Object Next TopicJava Object to String |
We provides tutorials and interview questions of all technology like java tutorial, android, java frameworks
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India