[ 
https://issues.apache.org/jira/browse/LANG-1161?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Sebb resolved LANG-1161.
------------------------
    Resolution: Invalid

I think this is behaving as per the documentation; the empty string always 
matches the start of a string.

Null is different - remember that null never equals anything except itself.

> StringUtils.startsWith returns true for an empty string comparison
> ------------------------------------------------------------------
>
>                 Key: LANG-1161
>                 URL: https://issues.apache.org/jira/browse/LANG-1161
>             Project: Commons Lang
>          Issue Type: Improvement
>    Affects Versions: 3.3
>            Reporter: Nicholas DeFazio
>            Priority: Trivial
>
> When working on a project I noticed that...
> {code}
>         boolean match = StringUtils.startsWith("abcdef", "");
>         System.out.println(match); //prints true
> {code}
> I'm not sure if this is intended, but my thought was that a comparison of a 
> non empty string to an empty string should result in a false, similar to how 
> null is handled.
> {code}
>         boolean match = StringUtils.startsWith("abcdef", null);
>         System.out.println(match); //prints false
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to