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 Programmer Certification (SCJP/OCPJP) and the fly likes String.endsWith() 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 » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "String.endsWith()" Watch "String.endsWith()" New topic


umang bhartia
Ranch Hand

Joined: Sep 29, 2000
Posts: 60
class end
public static void main(String[] args)
Output: True
Can any one explain how the output is true
Axl Rose

Joined: Dec 18, 2000
Posts: 16
note that the method endsWith(""), takes actually an empty string, or a string that contains nothing, not a single character.
and if we compare it with what the java doc say about the method endsWith(String argument)in the String class:
"Note that the result will be true if the argument is the empty string or is equal to this String object as determined by the"
so the answer will be true.
It is sorta covered in the JavaRanch Style Guide.
subject: String.endsWith()
It's not a secret anymore!