help please i am lost - illegal start of expression

publicclass PhoneCompany

{

private ArrayList<Account> accounts;

private ArrayList<TextMessage> textMessages;

privateint collectRevenues;

/**

* Constructor for objects of class PhoneCompany

*/

public PhoneCompany()

{

accounts =new ArrayList<Account>();

textMessages =new ArrayList<TextMessage>();

collectRevenues = 0;

}

publicvoid readAccounts(String fileName)

{

String[] lines = LineIO.readAllLines (fileName);

for (String line : lines)

{

String [] a = line.split("&");

if(line.startsWith("p")){

PrepaidAccount p =new PrepaidAccount(a[1], a[2], a[3], Integer.parseInt(a[4]), 30);

accounts.add(p);

}

if(line.startsWith("c")){

ContractAccount c =new ContractAccount(a[1], a[2], a[3], Integer.parseInt(a[5]), Integer.parseInt(a[6]), a[4]);

accounts.add(c);

}

{

System.out.println(line);

}

}

}

publicvoid readTextMessages(String fileName)

{

String[] lines = LineIO.readAllLines (fileName);

for (String line : lines)

{

String [] b = line.split("&");

if(line.startsWith("t")){

TextMessage t =new TextMessage(b[1], b[2], b[3], b[4]);

textMessages.add(t);

}

{

System.out.print(line);

}

}

}

{

publicvoidint collectRevenues()

{

int total = 0;

for (Account a: accounts)

{ total += a.collectRevenue();}

return total;

}

}

}

[3384 byte] By [gold_eyea] at [2007-11-26 12:21:30]
# 1
Where?
CaptainMorgan08a at 2007-7-7 15:13:14 > top of Java-index,Archived Forums,Socket Programming...
# 2
{public void int collectRevenues(){int total = 0; for (Account a: accounts) { total += a.collectRevenue(); } return total;}
gold_eyea at 2007-7-7 15:13:14 > top of Java-index,Archived Forums,Socket Programming...
# 3

{

public void int collectRevenues()

{

int total = 0;

for (Account a: accounts)

{ total += a.collectRevenue(); }

return total;

}

gold_eyea at 2007-7-7 15:13:14 > top of Java-index,Archived Forums,Socket Programming...
# 4
Make sure that method is not inside another method. It would help if you indented your code properly.
CaptainMorgan08a at 2007-7-7 15:13:14 > top of Java-index,Archived Forums,Socket Programming...
# 5
i dont think i want the void
gold_eyea at 2007-7-7 15:13:14 > top of Java-index,Archived Forums,Socket Programming...
# 6
> i dont think i want the voidThat too.
CaptainMorgan08a at 2007-7-7 15:13:14 > top of Java-index,Archived Forums,Socket Programming...
# 7
You can't return a void and an int at the same time.MeTitus
Me_Titusa at 2007-7-7 15:13:14 > top of Java-index,Archived Forums,Socket Programming...
# 8
how should be indented then
gold_eyea at 2007-7-7 15:13:14 > top of Java-index,Archived Forums,Socket Programming...
# 9
i have taken away the void and it still dont work
gold_eyea at 2007-7-7 15:13:14 > top of Java-index,Archived Forums,Socket Programming...
# 10

this is how I do it

public void int collectRevenues()

{

int total = 0;

for (Account a: accounts)

{

total += a.collectRevenue();

}

return total;

}

MeTitus

Me_Titusa at 2007-7-7 15:13:14 > top of Java-index,Archived Forums,Socket Programming...
# 11
> i have taken away the void and it still dont workWell then check to make sure that it is not inside another method. You seem to have many random braces floating around.
CaptainMorgan08a at 2007-7-7 15:13:14 > top of Java-index,Archived Forums,Socket Programming...
# 12

i have changed it too.....but still the same error message

{

public int collectRevenues()

int total = 0;

for (Account a: accounts)

{ total += a.collectRevenue(); }

return total;

}

gold_eyea at 2007-7-7 15:13:14 > top of Java-index,Archived Forums,Socket Programming...
# 13
Why did you surround it by braces?
CaptainMorgan08a at 2007-7-7 15:13:14 > top of Java-index,Archived Forums,Socket Programming...
# 14
class delimiters? maybe MeTitus
Me_Titusa at 2007-7-7 15:13:14 > top of Java-index,Archived Forums,Socket Programming...
# 15
thanks all is well
gold_eyea at 2007-7-7 15:13:16 > top of Java-index,Archived Forums,Socket Programming...
# 16

This is correct:

public void int collectRevenues()

{

int total = 0;

for (Account a: accounts)

{

total += a.collectRevenue();

}

return total;

}

but also you sould check if your java compiler is 1.5, because 1.4 dont support for:each statemments: (Account a: accounts)

Chaka at 2007-7-7 15:13:16 > top of Java-index,Archived Forums,Socket Programming...
# 17
> This is correct:No it isnt.
CaptainMorgan08a at 2007-7-7 15:13:16 > top of Java-index,Archived Forums,Socket Programming...
# 18

> This is correct:

>

> public void int collectRevenues()

> {

>int total = 0;

>

>for (Account a: accounts)

> {

> total += a.collectRevenue();

>

>return total;

>

> but also you sould check if your java compiler is

> 1.5, because 1.4 dont support for:each statemments:

> (Account a: accounts)

How is it correct?

I didn't know you could have functions return two different types of objects/type.

MeTitus

Me_Titusa at 2007-7-7 15:13:16 > top of Java-index,Archived Forums,Socket Programming...
# 19
man I think you got to the wrong forum.You should go to: www.verynewtoprogramming.comMeTitus
Me_Titusa at 2007-7-7 15:13:16 > top of Java-index,Archived Forums,Socket Programming...
# 20

Plus, whitespace doesnt matter in Java. His method could look like this and still work:

public int collectRevenues(){int total = 0;for(Account a:accounts){total+=a.collectRevenue();}return total;}

CaptainMorgan08a at 2007-7-7 15:13:16 > top of Java-index,Archived Forums,Socket Programming...
# 21
is it cuz u have private int collectRevenues; at the top of ur prog for no reason
j00Baga at 2007-7-7 15:13:16 > top of Java-index,Archived Forums,Socket Programming...