Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / First Aid / April 2004

Tip: Looking for answers? Try searching our database.

Why does String.indexOf() accept an int, and not a char?

Thread view: 
Inertia_sublimation - 04 Apr 2004 06:40 GMT
It seems a bit odd that String's indexOf() method accepts an int and not a
char, is there a special reason for this?

Thanks in advance!
Ryan Stewart - 04 Apr 2004 13:59 GMT
> It seems a bit odd that String's indexOf() method accepts an int and not a
> char, is there a special reason for this?
>
> Thanks in advance!

What's the difference? str.indexOf(65) is identical to str.indexOf('A') and
both of them will compile.
Kristoffel - 04 Apr 2004 19:15 GMT
> It seems a bit odd that String's indexOf() method accepts an int and not a
> char, is there a special reason for this?
>
> Thanks in advance!

1) to do things without cast:

    int i = 5;
    s.indexOf ('a' + i);

2) languages that needs more than 65536 characters.


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.