Expiring Today—Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Strings.......

Posted on 2002-04-04
6
Medium Priority
?
186 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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 1

Expert Comment

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

Accepted Solution

by:
CEHJ earned 15 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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
This video teaches viewers about errors in exception handling.

718 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