Solved

Strings.......

Posted on 2002-04-04
6
178 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
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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
network + 7 81
java. non-English characters encoding problem. intellij idea 3 74
GUI builder for Eclipse? 8 27
VB Script to add site to Java Exception List 4 53
After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.

863 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now