Solved

Strings.......

Posted on 2002-04-04
6
182 Views
Last Modified: 2010-03-31
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?
0
Comment
Question by:Codster
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 86

Expert Comment

by:CEHJ
ID: 6917798
Are you saying that (String)data[0][1] is equal to null, when you expected it to contain a report name?
0
 
LVL 1

Expert Comment

by:tonejunkie
ID: 6917873
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();
jstrings.addElement(reportname);

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

//You might have to cast it, because it will
//return an object and not a String.
(jstrings.elementAt(1)).toString();
0
 

Author Comment

by:Codster
ID: 6917950
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
0
SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

 
LVL 1

Expert Comment

by:tonejunkie
ID: 6917984
Why would that require arrays?
0
 
LVL 86

Accepted Solution

by:
CEHJ earned 5 total points
ID: 6918086
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'
0
 
LVL 92

Expert Comment

by:objects
ID: 6920057
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.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
Suggested Courses

751 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question