Length,length () in Java, size () difference
Length property: Used to get the length of the array.
eg
int ar[] = new int{1,2,3}
/**
* Array with the Length property to get the lengths/
int lenar = ar.length;//here lenar=3
System.out.println ("ARR length:" +lenar);
Length () Method: Used to get the length of the string.
String str = "Hello world Java";
the/** * string uses the length () method to obtain
the lengths */
int lenstr = Str.length ();//Here lenstr=16
System.out.println ("str Length (): "+lenstr";
Size () Method: lets you get the number of elements in a generic collection.
eg
/**
* Collection is the largest parent interface for single value saving in the entire class set, so it is necessary to instantiate it with a specific subclass * *
collection<string> col = new ArrayList <String> ();
Col.add ("Hello");
Col.add ("World");
Col.add ("Java");
/**
* Class set framework using the size () method to take the number of elements/
int sizecol = Col.size ();//Here sizecol=3
System.out.println ("Col size : "+sizecol);
Thank you for reading, I hope to help you, thank you for your support for this site!