I'm new to JAVA and I have a very simple question when I'm writing some codes. When should i use length and when should i use length()?
What's the difference between length and size?
Thank you!
I'm new to JAVA and I have a very simple question when I'm writing some codes. When should i use length and when should i use length()?
What's the difference between length and size?
Thank you!
 
    
    length --- arrays (int[], double[], String[]) ---- to know the length of the arrays.
length() --- String related Object (String, StringBuilder etc)to know the length of the String
size() ---  Collection Object (ArrayList, Set etc)to know the size of the Collection 
as length is not a method its works on arrays not on objects. 
size() is a method which work on collection frameworks as i said up there .
now String is not a direct array and also not a Collection that's why we also need a different one which is length().
