• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Problems faced in returning String array

 
Zibia Rajakumari
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator



When returning this array, i got error as variable might not have been initialized., can anyone Please help me how to solve this.........


[HENRY: Added Code Tags]
[ June 08, 2008: Message edited by: Henry Wong ]
 
Rob Spoor
Sheriff
Pie
Posts: 20545
56
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
First of all, UseCodeTags. It will make it easier for people to read.

As for your error, it is not in the code you have provided. I have copied this, declared videoCrytoLineA and videoCrytoLineB as private fields (which I assume they are) and compiled. Worked like a charm. Can you post the entire error message? Something like what I got when I removed the import for StringTokenizer:



On a side note, you have made one huge logical error in the following two lines:

The toString() method of StringBuffer (and StringBuilder) returns a new String object with the current contents of the StringBuffer. This String has no connection to the StringBuffer at all. Therefore, when you update the StringBuffer, the String will not change!

You should move these two lines to the end, just before you return the array, as that's the first point where the StringBuffers will no longer be updated and their contents are final.

Oh, and this is a problem with Java in General, so that's where this thread is moving.
[ June 08, 2008: Message edited by: Rob Prime ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic