Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Jun 13th, 2006, 3:57 PM   #11
Jimbo
Battle Programmer
 
Jimbo's Avatar
 
Join Date: Feb 2006
Location: Bellevue, WA, USA
Posts: 763
Rep Power: 3 Jimbo is on a distinguished road
I don't know if this works, but...
private static String makeStr(int num) {
    return new String((char)('a' + num / 26)) + (char)('a' + num % 26);
}
Jimbo is offline   Reply With Quote
Old Jun 13th, 2006, 9:58 PM   #12
titaniumdecoy
Expert Programmer
 
titaniumdecoy's Avatar
 
Join Date: Nov 2005
Posts: 855
Rep Power: 3 titaniumdecoy is on a distinguished road
Send a message via AIM to titaniumdecoy
Jimbo, that works, but with a little modification:

private static String makeStr(int num) {
    return String.valueOf((char)('a' + num / 26)) + (char)('a' + num % 26);
}
Not only is the following code simple, but it's also faster, since it creates only one String object:

private static String makeStr(int num) {
    return new String(new char[]{ (char)('a' + num / 26), (char)('a' + num % 26) });
}
I want my $1! :p
titaniumdecoy is offline   Reply With Quote
Old Jun 14th, 2006, 7:46 AM   #13
Gumby
Newbie
 
Join Date: Mar 2006
Location: Andover, MA / Rochester, NY / Nanticoke, PA
Posts: 16
Rep Power: 0 Gumby is on a distinguished road
Send a message via AIM to Gumby
Quote:
Originally Posted by titaniumdecoy
Jimbo, that works, but with a little modification:

private static String makeStr(int num) {
    return String.valueOf((char)('a' + num / 26)) + (char)('a' + num % 26);
}
Not only is the following code simple, but it's also faster, since it creates only one String object:

private static String makeStr(int num) {
    return new String(new char[]{ (char)('a' + num / 26), (char)('a' + num % 26) });
}
I want my $1! :p
checks in the mail
Gumby is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 6:40 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC