How to use the length method of string in Julia
Overview
The length method returns the length of the provided string.
Syntax
length(S::AbstractString)
Parameter
This method takes the String as an argument.
Return value
This method returns an Integer value denoting the length of the provided String.
Example
The code below demonstrates the use of the length method:
# Using length method to get length of "Educative"println(length("Educative"))# Using length method to get length of empty stringprintln(length(""))
Explanation
In the code above:
-
Line 2:. We use the
lengthmethod to get the length of the String"Educative". We get9as the return value. -
Line 5:. We use the
lengthmethod to get the length of an Empty String"". We get0as the return value.