Google+

94. '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:



Download this project:

Click here to download this project containing 'StringDemo' class file used in this post (You can download the project and import into Eclispe IDE on your machine)




Please comment below to feedback or ask questions.

How to use '+' operator to  concatenate two strings will be explained in the next post.



No comments: