Search code examples
blackberryblackberry-simulator

what's wrong with concatenation in blackberry application?


For the life of me, I can't understand why adding a concatenated string to the MainScreen is causing the BB simulator to throw an exception. If I run a VERY simple hello program with the following control, all is well:

RichTextField rtfHello = new RichTextField("Hello There !!!");        
add(rtfItemDescription);

But if I add a concatenated string, the entire app breaks:

String MyName = "John Doe";
RichTextField rtfHello = new RichTextField("Hello There !!!" + MyName);        
add(rtfItemDescription);

So what am I doing wrong? Why would the simulator throw an exception for the second example?


Solution

  • Not sure why it would blow up (but I'm not a blackberry/java developer). Have you simply tried:

    String MyName = "John Doe"; 
    String HelloString = "Hello There !!!";
    RichTextField rtfHello = new RichTextField(HelloString.concat(MyName));         
    add(rtfItemDescription); 
    

    Or simply,

    String MyName = "John Doe"; 
    RichTextField rtfHello = new RichTextField("Hello There!!!".concat(MyName));         
    add(rtfItemDescription);