i have an array of strings declared as so:
String[] jstrings =
"<html><H2><B><FONT COLOR=Black>Name</H2></HTML>", //jstring[0]
" ", //jstring[1]

i then retrieve a value from a database known as report name which i want to set as the text in jstring[1]. This is done using
jstring[1] = reportname;
from debugging i know that the correct result is contained in jstring[1] after this.

however i wish to display these strings in a table using:
Object [][] data = {
{jstrings[0], jstrings[1], " ", " "},
{jstrings[2], " ", " ", " "},

but jstring[1] contains a null value at this point!

can anyone help?
Who is Participating?
CEHJConnect With a Mentor Commented:
We'll talk about containers later. What we need to know is everything that happens between your valid string and your invalid string.

First of all, confirm that 1 and 2 below are correct propostions, then show the code in between:

1. System.out.println(jstrings[1]) gives a valid report name.
2. System.out.println((String)data[0][1]) gives 'null'
Are you saying that (String)data[0][1] is equal to null, when you expected it to contain a report name?
Codster,  I'd look into using collections such as Vector, instead of arrays.  There's almost no need for arrays in Java (almost).

//This way you can do:
Vector jstrings = new Vector();

//Then to display the string contained in
//a certain place (let's say 1):

//You might have to cast it, because it will
//return an object and not a String.
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

CodsterAuthor Commented:
yes the string should contain report name

i am using arrays because there are many elements in the array not just the three that i specified
Why would that require arrays?
Need to see more code, from what you've shown there is no way that either jstrings[1] or data[0][1] could be null.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.