Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to intialize large String content in string literal?

 
santhosh.R gowda
Ranch Hand
Posts: 296
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I had a large string content which consists of more than 10 thousand words, hence each time i called the respective java the string gets initialized,so it hits performance,is there any way to improve performance?
 
R. Jain
Ranch Hand
Posts: 375
1
Java Python Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
santhosh.R gowda wrote:Hi,
I had a large string content which consists of more than 10 thousand words, hence each time i called the respective java the string gets initialized,so it hits performance,is there any way to improve performance?


Is that string fixed all over your application or you are supposed to modify it??
 
Winston Gutkowski
Bartender
Pie
Posts: 10236
58
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
santhosh.R gowda wrote:I had a large string content which consists of more than 10 thousand words

The term "large string content" covers a multitude of sins. Where does it come from? A file? A database? If a file, is that file arranged in lines? All these things will have an effect on how you proceed.

Second: Don't obsess about efficiency, either for space or speed. Get it right. Tweaks for efficiency can always come later, and 10,000 words is 150K or so - peanuts for most modern machines. If it were 10 million words, you might have cause for worry, but even then my advice would be the same: get it right first.

Winston
 
Campbell Ritchie
Sheriff
Posts: 48652
56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
santhosh.R gowda wrote: . . . each time i called the respective java the string gets initialized, . . .
I don’t understand that bit. Do you mean the String is initialised every time you start the JVM? Does it actually have more than one initialisation per execution?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic