🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.jbuilder.java.language
Article #19750

Re: String Array.... Help Please...

#19750
From: Paul Murray
Date: Thu, 25 Dec 1997 00:00
39 lines
1673 bytes
>I am trying to create a String Array of labels that after I have read
>from the file I can
>pass it through to SetLabels method of my Status bar.
>
>I have it setup like this.
>String Temp;             // Variable that gets the string read in from
>the file.
>String BBLables[];    // This should create an Array I thought.
>int Counter = 0;        // Go through the Array.
>
>// Then I just say:
>BBLabels[Counter] = Temp;
>Counter++;
>
>and this does not work....
>What am I doing wrong?


Ok.
This:
>String BBLables[];    // This should create an Array I thought.
Does not create an array. It creates a reference to an array of string. This
reference is currently null. To create an array for that reference to point
at, you need

String[] BBLables = new String[MAX_COUNT];

Once again,
>String Temp;             // Variable that gets the string read in from
Does not create a string: it creates a reference to a string. You create a
string either with a "new String()", or by calling a function that returns a
String, eg: the read line functions

counter = 0;
while(counter < MAX_COUNT)
    BBLabels[counter++] = file.read_a_line();

Hope this helps
Technical Details
Message-ID: <685iub$nn66@forums.borland.com>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <34A3DC17.F85BD328@whitehouse.acl.ca>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f74b3,2583ba01705f56ce,start
X-Google-Attributes: gidf74b3,public
From: "Paul Murray" <pmurray@bigpond.com>
Subject: Re: String Array.... Help Please...
Date: 1997/12/25
Message-ID: <685iub$nn66@forums.borland.com>
X-Deja-AN: 310749080
References: <34A3DC17.F85BD328@whitehouse.acl.ca>
X-MimeOLE: Produced By Microsoft MimeOLE V4.71.1712.3
Organization: N/A
Newsgroups: borland.public.jbuilder.java.language