- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How many ways a String object can be created in java?
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);
- Related Articles
- What are all the ways an object can be created in Java?
- How many ways can a property of a JavaScript object be accessed?
- How many types of JDialog boxes can be created in Java?
- In how many ways we can convert a String to a character array using Java?
- In how many ways can we split a string in JavaScript?
- 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 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?
- How many ways to iterate a LinkedList in Java?
- How many ways to iterate a TreeSet in Java?
- In how many ways can I compare Strings in Java explain with example?

Advertisements