'String' class

String is probably the most commonly used class in Java's class library. Every string you create is actually an object of type String class.



String myString ="This is my string";
  • String - It is a class
  • myString - Its an object of 'String' class type
  • "This is my string" - We have assigned this text to the 'myString' object of  'String' class type


Lets implement this on Eclipse IDE:

1. Create 'StringDemo' class under an project as shown below:


2. Save and Run the 'StringDemo' class file
3. Observe that the output is displayed in console as shown below: