String Data Type In Java

aimtocode.COM

String Data Type ?

Java string data type is also a class, and so it has its own methods. These options include finding string length, converting to upper or lower case, trimming text, or replacing text within the string. Let's take a look at some of these and show some code samples. In order to invoke the method, type the name of the variable followed by a period, and the method name.


This is perhaps the most-used method, because it can be used within other string manipulation routines. Once you know the length of the string, you can take out pieces of the string, or even try to enforce certain limitations on them. The method for finding the length is the length() method:

String Literals are always enclosed in double quotes and are implemented using the java.lang.String class. Enclosing a character string within double quotes will automatically create a new String object


aimtocode.COM

Example 1:



Output :

 hello.
aimtocode.COM

Example 2:



Output :

 String Length is : 17

Example 3:



Output :

aimtocode: I saw I was studying
aimtocode.COM