return array of strings to class

S

sazykin

Hi,

i'm wriritng a smal programm and i whant to return array of string to
class here is an example i whant to do...

public class CreateArray{

public static String[] create_str_array(){


//here i'm reading a txt file to string array..

StringArray = dis.readLine(); i++;

then i'm trying to return my array with

return (String[])(line)
}}

ok no i supposed to have array of strings and i would like to access it
in my new class

public class AccessArray{

public static accessArray(String[] StringArray) {

//and here comes that i dont know how can access my array....
I have tried:

CreateArray[] StringArray = new CreateArray[20];
for (int i=0; i>10;i++)
String newArray = line.create_str_array();

//but this doesnt seems to work. please help....


}}

i whant to have pass exactly the same array to this class from my
CreateArray class

thanx
 
P

Patricia Shanahan

for (int i=0; i>10;i++)

Zero is not greater than ten, so this loop does no iterations. Perhaps
you meant "for (int i=0; i<10; i++)", which would do ten iterations?

Patricia
 
S

sazykin

Patricia said:
Zero is not greater than ten, so this loop does no iterations. Perhaps
you meant "for (int i=0; i<10; i++)", which would do ten iterations?

Patricia

yes u right... but this not a problem at the moment...
 
I

Ingo R. Homann

Hi,

Please post a real example. I expect, thas was not your real code, was it?

Something like:

String[] getStringArray() {
return new String[]{"x","y"};
}

Ciao,
Ingo
 
P

Patricia Shanahan

yes u right... but this not a problem at the moment...

It is the sort of thing that COULD be a part of your problem.

The code snippets you posted have various problems. How about a
complete, compilable, runnable program that is correct in everything
except the piece you are having trouble with?

Patricia
 
M

Mike Schilling

Patricia Shanahan said:
It is the sort of thing that COULD be a part of your problem.

The code snippets you posted have various problems. How about a
complete, compilable, runnable program that is correct in everything
except the piece you are having trouble with?

And some proofreading or at least spell-checking of the text. You're asking
people to help you; spending a little time on readability is a worthwhile
gesture.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,772
Messages
2,569,593
Members
45,112
Latest member
VinayKumar Nevatia
Top