StringBuffer problem

This is where you talk about the NXJ software itself, installation issues, and programming talk.

Moderators: imaqine, 99jonathan, roger

New User
Posts: 24
Joined: Fri Nov 16, 2007 6:18 pm
Location: Russia

StringBuffer problem

Postby vladra » Thu Nov 29, 2007 4:28 pm

This code doesn't work properly. A code after sb.append never be executed when i==0.

Code: Select all

StringBuffer sb = new StringBuffer(20);
int i = 0;

Infinite loop (?) occurs when StringBuffer.append calls Math.log.

What about Math.log I don't know. I think it's necessary to add the following code at the top of StringBuffer.append:

Code: Select all

public StringBuffer append (int aInt)
    if( aInt==0 )
        characters[ curPos++ ] = '0';
        return this;

leJOS Team Member
Posts: 965
Joined: Mon Feb 05, 2007 1:27 pm

Postby lawrie » Thu Nov 29, 2007 5:05 pm

Thanks for the fix - I have applied it to the development version and it will be in the next release. I hit a problem with StringBuffer recently and had it on a list of things to investigate before the next releaase. I think it was the same bug. We will need to investigate Math.log sometime. The problem was never reported on the RCX, so I don't know if the bug is specific to the NXT.

Return to “NXJ Software”

Who is online

Users browsing this forum: No registered users and 2 guests