Saturday 2 July 2016

difference betweeh length and length() in java

difference betweeh length and length() in java

description : To find the length of array we use legth.

ex : define and intiger array and find the length of the array.
int[] number =  new int[3];
number[0] = 1;
number[1] = 3;
number[2] = 5;

int secondHighest = number.length;
output : 3

description : To find the length of string we use legth().

String name = "voice";
System.out.println(name.length() + " length");

output : 5

No comments:

Post a Comment