This is a tricky question asked in java interviews.
The main purpose of
both are same as they are used for calculating the length but the difference
can be understand by the definition of both mentioned below:
The length() method is used for calculating the length of
the String variable in java.
The length property is used to calculate the length of the
Array in java.
Example:-
public
class ArrayTest
{
public static void main(String[] args)
{
int[] test = {12,1,4};
String test2 = "Hoo";
System.out.println(test.length);
System.out.println(test2.length());
}
}
interesting piece of information, I had come to know about your web-page from my friend pramod, jaipur,i have read atleast eight posts of yours by now, and let me tell you, your blog gives the best and the most interesting information. This is just the kind of information that i had been looking for, Thanks a million once again, Regards, sql and plsql difference
ReplyDeleteThanks Nandkishor for your encouraging words..
Delete