This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes length method not with braces Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Beginning Java
Bookmark "length method not with braces" Watch "length method not with braces" New topic
Author

length method not with braces

shivam aggarwal
Greenhorn

Joined: Oct 15, 2009
Posts: 8
why is 'length' method not used with usual braces,unlike other methods?
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 20078
    
  30

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 - OCEEJBD 6 - OCEJPAD 6
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: 43935
    
  33
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.
 
Have you checked out Aspose?
 
subject: length method not with braces
 
It's not a secret anymore!