Forums Register Login

Help with arrays/class

+Pie Number of slices to send: Send

i got a Cannot resolve symbol error. what i am trying to do is create a number of accounts(depending on user input) and do id verification. is it possible for me to get back the input tt i got in createacc and use it in check?
[JAM -- added [CODE] and [/CODE] tags]
[ April 17, 2004: Message edited by: Joel McNary ]
+Pie Number of slices to send: Send
check where you have declared the Acc[] acct = new Acc[i]; it is with in the create() method...make acct global...and it should work
+Pie Number of slices to send: Send
class Acc
{
//assume constructor etc is done
Acc[] acct = new Acc[i];
public int createacc()
{
System.out.println("How many accounts?");
i = cs.readInt();
Acc[] acct = new Acc[i];
do u mean like this? i get an array index out of bounds error now(during run time), in:
if(getid.compareTo(acct[j].id) == 0)
+Pie Number of slices to send: Send
class Acc
{
Acc[] acct;
public int createacc()
{
for (j=0;j<=count;j++)
{
acct[j].bal = (acct[j].bal)*1.5;
}
return i;
}
public int checkid(int i)
{ //error here
//code omitted
}
}
i dont know why, but i got this Return statement not initialised/assigned error on my code. can someone help?
+Pie Number of slices to send: Send
hi tian,
you took my statement literally, what I meant was to declare the acct globally and initialize the array in the create()..this way the visibility of the acct will be to all the methods in the class. earlier you declared and initialized within the create() method so you got cannot resolve symbol error.
I am reproducing the code here with changes...just go through it.
The only taste of success some people get is to take a bite out of you. Or this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 928 times.
Similar Threads
adding to an existing array
question about treemaps
Stumped, need inspiration.
Game: ATM machine problem
help with arrays
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 29, 2024 08:02:24.