

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- 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 to get the Length of a String in Java?
You can get the length of a string using the length() method of the String class. The length is equal to the number of 16-bit Unicode characters in the string.
Example
import java.io.*; public class Test { public static void main(String args[]) { String Str1 = new String("Welcome to Tutorialspoint.com"); String Str2 = new String("Tutorials" ); System.out.print("String Length :" ); System.out.println(Str1.length()); System.out.print("String Length :" ); System.out.println(Str2.length()); } }
Output
String Length :29 String Length :9
- Related Questions & Answers
- How to get the length of a string in Python?
- How to get the length of a string in JavaScript?
- How to get the length of longest string in a PHP array
- Get the length of a StringBuffer Object in Java
- How to get the length of a Number in JavaScript?
- How do I get the average string length in MySQL?
- PHP – Get the string length using mb_strlen()
- How to get the length of an object in JavaScript?
- How to get length of a list of lists in Python?
- C++ Program to Find the Length of a String
- C program to find the length of a string?
- How do I get length of list of lists in Java?
- How to calculate the length of the string using C#?
- How to get the current length of the Text in a Tkinter Text widget?
- Java string length without using length() method.
Advertisements