- Related Questions & Answers
- How many ways can a property of a JavaScript object be accessed?
- What are all the ways an object can be created in Java?
- How many types of JDialog boxes can be created in Java?
- In how many ways can we split a string in JavaScript?
- In how many ways we can convert a String to a character array using Java?
- Can a final variable be initialized when an object is created in Java?
- In how many ways we can concatenate Strings in Java?
- In how many ways can we find a substring inside a string in javascript?
- How many ways to make an object eligible for GC in Java?
- How many ways to iterate a TreeSet in Java?
- How many ways to iterate a LinkedList in Java?
- How many ways can get the instance of a Class class in Java?
- In how many ways you can retrieve the elements of a collection in Java?
- How many ways can we read data from the keyboard in Java?
- In how many ways can I compare Strings in Java explain with example?

- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who

You can create a String by −

**Step 1** − Assigning a string value wrapped in " " to a String type variable.

String message = "Hello Welcome to Tutorialspoint";

**Step 2** − Creating an object of the String class using the new keyword by passing the string value as a parameter of its constructor.

String message = new String ("Hello Welcome to Tutorialspoint");

**Step 3** − Passing a character array to the String constructor.

char arr[] = {'H','e','l','l','o'}; String message = new String(arr);

Advertisements