plz help
what is the difference between lenght and length()..... no spamming plz.
Its related to java
At least 2 points needed.
Answers
Answered by
3
length | length ()
>It is used to find the | >It is used to find the length of a String
length of an array. |
>It is an array function. | >It is String function
>int n={1,5,7,8,9}.length; | > int s = ”Computer”.length()
o/p=5. |. o/p=8
>It is used to find the | >It is used to find the length of a String
length of an array. |
>It is an array function. | >It is String function
>int n={1,5,7,8,9}.length; | > int s = ”Computer”.length()
o/p=5. |. o/p=8
Guptamonika:
thanx for helping him
Answered by
6
Short note on length and length() in Java:
(1) Length:
(a) It is applicable only for arrays.
(b) It returns the size of an Array.
Ex: int[] a = new int[5];
System.out.println(a.length);
Output: 5.
(2) Length():
(a) It is applicable for string objects.
(b) It returns the number of characters present in the string.
Ex: String site="Brainly";
System.out.println(site.length());
Output: 7.
Hope this helps!
(1) Length:
(a) It is applicable only for arrays.
(b) It returns the size of an Array.
Ex: int[] a = new int[5];
System.out.println(a.length);
Output: 5.
(2) Length():
(a) It is applicable for string objects.
(b) It returns the number of characters present in the string.
Ex: String site="Brainly";
System.out.println(site.length());
Output: 7.
Hope this helps!
Similar questions