Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

length method not with braces

 
shivam aggarwal
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
why is 'length' method not used with usual braces,unlike other methods?
 
Rob Spoor
Sheriff
Pie
Posts: 20527
54
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
samir singha
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you use String in your code you will find length() method with braces.
 
Campbell Ritchie
Sheriff
Posts: 48910
58
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Braces look like this: {}

What you showed () are called parentheses (in America) or sometimes (round) brackets (in Britain), never braces.
 
samir singha
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You are right ritchie. Though I knew the differance, I have done the mistake unknowingly.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic