Chapter: Java The Complete Reference - The Java Library - String Handling

Study Material, Lecturing Notes, Assignment, Reference, Wiki description explanation, brief detail

String Length - Java

The length of a string is the number of characters that it contains. To obtain this value, call the length( ) method, shown here:

String Length

 

The length of a string is the number of characters that it contains. To obtain this value, call the length( ) method, shown here:

 

int length( )

 

The following fragment prints "3", since there are three characters in the string s:

 

char chars[] = { 'a', 'b', 'c' }; String s = new String(chars); System.out.println(s.length());


Study Material, Lecturing Notes, Assignment, Reference, Wiki description explanation, brief detail


Copyright © 2018-2020 BrainKart.com; All Rights Reserved. Developed by Therithal info, Chennai.