Two Laptop Bag
The moose likes Beginning Java and the fly likes Problems faced in  returning String array Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of OCA Java SE 8 Programmer I Study Guide this week in the OCAJP 8 forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Problems faced in  returning String array " Watch "Problems faced in  returning String array " New topic

Problems faced in returning String array

Zibia Rajakumari

Joined: Jun 08, 2008
Posts: 2

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

Joined: Oct 27, 2005
Posts: 20132

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 ]

How To Ask Questions How To Answer Questions
I agree. Here's the link:
subject: Problems faced in returning String array
It's not a secret anymore!