Formatting of strings
- From: Ulf <ulf.hemma@xxxxxxxxx>
- Date: Sun, 30 Mar 2008 12:53:36 -0700 (PDT)
I'm looking for the best way to combine two strings so that the result
ends with the 2:nd string in position 30-32. The 1:st string is 1 to
30 chars long.
Currently I use the following (untested) code.
char cc[] = new char[33];
for(int i = 0; i < 33; i++) { cc[i] = ' '; } //Make spaces
cc[30] = '/'; // This is the 3 chars for string2
cc[31] = '0';
cc[32] = '0';
string1.getChars(0,string1.length()- 1, cc, 0);
resultString = new String(cc);
I would appreciate suggestions both on the solution (perhaps this is
the best solution) and proper Java coding.
This operation will be used just a few times a day, so the solution
really doesn't matter for the project, but it matters for me trying to
learn Java.
/Ulf
.
- Follow-Ups:
- Re: Formatting of strings
- From: Roedy Green
- Re: Formatting of strings
- From: GArlington
- Re: Formatting of strings
- From: Mark Space
- Re: Formatting of strings
- Prev by Date: Re: Byte to float conversion problem - PLEASE HELP
- Next by Date: "PriorityMap"
- Previous by thread: Re: Where do you keep contants in Interfaces or in classes?
- Next by thread: Re: Formatting of strings
- Index(es):
Relevant Pages
|