Author
length method not with braces
shivam aggarwal
Greenhorn
Joined: Oct 15, 2009
Posts: 8
posted Oct 15, 2009 08:38:08
0
why is 'length' method not used with usual braces,unlike other methods?
Rob Spoor
Sheriff
Joined: Oct 27, 2005
Posts: 19216
If you are talking about the .length attribute of arrays, the answer is pretty simple - it's not a method. You might say it's something like a public final int field - you can read it but not change it.
SCJP 1.4 - SCJP 6 - SCWCD 5
How To Ask Questions How To Answer Questions
samir singha
Greenhorn
Joined: Mar 17, 2008
Posts: 23
If you use String in your code you will find length() method with braces.
Campbell Ritchie
Sheriff
Joined: Oct 13, 2005
Posts: 32611
Braces look like this: {}
What you showed () are called parentheses (in America) or sometimes (round) brackets (in Britain), never braces.
samir singha
Greenhorn
Joined: Mar 17, 2008
Posts: 23
You are right ritchie. Though I knew the differance, I have done the mistake unknowingly.
subject: length method not with braces