Computer Science, asked by Akshat999, 1 year ago

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 Dårviñ714
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

Guptamonika: thanx for helping him
Dårviñ714: You're heartily welcome
Guptamonika: ☺☺
Answered by siddhartharao77
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!

siddhartharao77: Gud Luck!
Guptamonika: thanx for help
Akshat999: thnx
Similar questions