• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

StringBuffer

 
Fisher Daniel
Ranch Hand
Posts: 582
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear all,
I am writing an application that every some seconds will trigger a canvas to draw a string on the device's display.
I use StringBuffer object for that string.
So I have to delete the whole content and append new strings into that StringBuffer object before I call repaint() method.
I see on Memory Monitor that the number of StringBuffer objects, which are created, increase every time I trigger the canvas.

Is it the good design to use StringBuffer object instead of String object for my appliction?

thanks
daniel
 
Ko Ko Naing
Ranch Hand
Posts: 3178
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Fisher,
I feel like your quesiton is more related to J2ME forum, rather than this SCMAD forum, which is for topics related to the exam...

And I would give some comment on your design... If your String is to be updated several times... It'd better to use StringBuffer as in your design, rather than using String object, where you have to create each String object everytime you want to display on the canvas...

but you may find more creative design from folks at the J2ME forum, that I told you...

Just my 2 cents...
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic