This week's giveaway is in the Spring forum.
We're giving away four copies of REST with Spring (video course) and have Eugen Paraschiv on-line!
See this thread for details.
The moose likes Java in General and the fly likes length vs length() Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "length vs length()" Watch "length vs length()" New topic

length vs length()

Anand Divakaran

Joined: Jul 20, 2007
Posts: 6
when using string objects , when can i use str.length and str.length();
str is a object reference of type string
Ernest Friedman-Hill
author and iconoclast

Joined: Jul 08, 2003
Posts: 24195

You may call the "length()" method on a String, and access a "length" member variable on an array. String does not have a "length" member variable as arrays (appear to) have.

[Jess in Action][AskingGoodQuestions]
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
subject: length vs length()
It's not a secret anymore!