answersLogoWhite

0


Best Answer

String itself is an object dude...

If you want an object out of a string then you can do this.

Object obj = (Object) str; //str is the String you want to convert to object.

User Avatar

Wiki User

15y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: How can you make object from string in java?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

In java is A string the same thing as a char?

No.A char is a single Unicode character. It is stored as a primitive (i.e., non-object) data. A string can be considered as an array of chars - Java stores it as an object.No.A char is a single Unicode character. It is stored as a primitive (i.e., non-object) data. A string can be considered as an array of chars - Java stores it as an object.No.A char is a single Unicode character. It is stored as a primitive (i.e., non-object) data. A string can be considered as an array of chars - Java stores it as an object.No.A char is a single Unicode character. It is stored as a primitive (i.e., non-object) data. A string can be considered as an array of chars - Java stores it as an object.


What method that returns string representation of the contents of the variable?

Since the question is in the Java category: in Java, the method is called toString(). This method will automatically be invoked if you implicitly convert an object to String type, for example: "The answer is: " + myObject In this example, the String concatenation (the plus sign) forces the object, myObject, to type String - to do this, the object's toString() method will be called.


Where string is stored on Heap or Stack in java?

A String is treated as an object, meaning there is an object on the heap. Of course, the variable you define is a pointer to the object, and it is stored on the stack.A String is treated as an object, meaning there is an object on the heap. Of course, the variable you define is a pointer to the object, and it is stored on the stack.A String is treated as an object, meaning there is an object on the heap. Of course, the variable you define is a pointer to the object, and it is stored on the stack.A String is treated as an object, meaning there is an object on the heap. Of course, the variable you define is a pointer to the object, and it is stored on the stack.


How do you convert capital string to small in Java?

To convert a String object to lowercase in Java, use the toLowerCase() method. "HELLO".toLowerCase() returns a new String: "hello".


In Java what operator is used to determine if an object is of a particular class type?

The instanceof keyword is used to determine if an object is of a particular class type.Example:Object obj = new String();if(obj instanceof String) {System.out.println("obj is a String!");}

Related questions

What are the different between'a' and ''a in java string methods?

The difference between 'a' and "a" anywhere in Java is that 'a' is a primitive char type, while "a" is a String object.


In java is A string the same thing as a char?

No.A char is a single Unicode character. It is stored as a primitive (i.e., non-object) data. A string can be considered as an array of chars - Java stores it as an object.No.A char is a single Unicode character. It is stored as a primitive (i.e., non-object) data. A string can be considered as an array of chars - Java stores it as an object.No.A char is a single Unicode character. It is stored as a primitive (i.e., non-object) data. A string can be considered as an array of chars - Java stores it as an object.No.A char is a single Unicode character. It is stored as a primitive (i.e., non-object) data. A string can be considered as an array of chars - Java stores it as an object.


What is string buffer in java?

StringBuffer is java class available in java.lang package which provides mutable String object where String is immutable class. The methods of this class like reverse(), append(),insert() gives facility to insert data of the same object.


What method that returns string representation of the contents of the variable?

Since the question is in the Java category: in Java, the method is called toString(). This method will automatically be invoked if you implicitly convert an object to String type, for example: "The answer is: " + myObject In this example, the String concatenation (the plus sign) forces the object, myObject, to type String - to do this, the object's toString() method will be called.


Where string is stored on Heap or Stack in java?

A String is treated as an object, meaning there is an object on the heap. Of course, the variable you define is a pointer to the object, and it is stored on the stack.A String is treated as an object, meaning there is an object on the heap. Of course, the variable you define is a pointer to the object, and it is stored on the stack.A String is treated as an object, meaning there is an object on the heap. Of course, the variable you define is a pointer to the object, and it is stored on the stack.A String is treated as an object, meaning there is an object on the heap. Of course, the variable you define is a pointer to the object, and it is stored on the stack.


What is a string in java?

An object that stores an ordered set of characters (ie. "hello"). The String class represents character strings.


Is String in java a class or object?

String is a pre-defined class in Java. For example: String s = new String("This is a string"); the variable s is now a String object since it was declared and initialized in the String class.


What is use of serialization in java?

Serialization will turn a Java Object into a text string (representing it's contents) which can be persisted to a storage device or sent over a network. There is an opposite process of turning the text string representation back into an instanciated Object.


When does the memory created for an object?

Memory for a Java object gets created when the object is instantiated. For example private String name = "rocky"; At the end of this statement the memory for the string object name gets created in the memory.


How do you convert capital string to small in Java?

To convert a String object to lowercase in Java, use the toLowerCase() method. "HELLO".toLowerCase() returns a new String: "hello".


In Java what operator is used to determine if an object is of a particular class type?

The instanceof keyword is used to determine if an object is of a particular class type.Example:Object obj = new String();if(obj instanceof String) {System.out.println("obj is a String!");}


How do you pass objects to methods?

The same way as you pass a non-object parameter; for example: String x = "Hello"; doSomething(x); (In Java, a String is an object, but this works just as well with an object created with the "new" keyword.)