• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Devaka Cooray
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Martijn Verburg
  • Frits Walraven
  • Himai Minh

What is "" (blank String)?

 
Ranch Hand
Posts: 1710
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator



What is ""? Is it called blank String. So what the lastIndexOf() and firstIndexOf() methods searching for?



Regards,
cmbhatt
 
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Maybe I ask what firstIndexOf() is ? Where is it coming from ?

About lastIndexOf(), the rightmost empty string "" is considered to occur at the index value this.length().
 
Sheriff
Posts: 11343
Mac Safari Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Consider that the length of an empty String is zero. So we can find a zero-length substring at any index of any sample String -- including the index equal to the sample String's length (that is, the index following the final character in the String). Note that it would be impossible for this final index to denote the beginning of any substring with a length greater than zero.

Also see this topic in our SCJP FAQ, which deals with a similar concept.
[ April 09, 2007: Message edited by: marc weber ]
 
Chandra Bhatt
Ranch Hand
Posts: 1710
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Marc,

Perfect example to grasp the empty String ("").

By mistake I write firstIndexOf(), there is nothing like this method in the
String class.


Thanks again Marc.


Regards,
cmbhatt
 
I can't take it! You are too smart for me! Here is the tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic