In this section, you will learn how to get the length of given string. The lang package of java provides the facility for getting the length of string. You will see in the following program for getting the length of string by using the length() method that returns integer type value of any given string. After running this program takes any string in command line and calculates its length.
Description of code:
length():
This is the method that returns the length of given string in integer type.
Here is the code of program:
import java.lang.*;
|
Output of program:
| C:\vinod\Math_package>javac StringLength.java C:\vinod\Math_package>java StringLength String lenght example! Please enter string: RoseIndia.net String lenght : 13 |
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.
Ask Questions? Discuss: String length example View All Comments
Post your Comment