"illegal start of expression" error

4

In my main I'm calling the stats method:

user.stats(ctr);

The method stats itself:

public void stats (int num)
{
    int i;
    float total=0, perc;
    for (i=0;i<num;i++)
    {
        total = total + sensors[i].statistics.getTotalConsumption(sensors[i].statistics.data[]);
    }
}

The class users :

public class Users implements IUsers{
protected int id;
protected String name;
protected int age;
protected String email;
protected String phone;
protected Sensors sensors[] = new Sensors[10];
float cost;
float goal;

public Users()
{

}

public void stats (int num)
{
    int i;
    float total=0, perc;
    for (i=0;i<num;i++)
    {
        total = total + sensors[i].statistics.getTotalConsumption(sensors[i].statistics.data[]);
    }
}
}

O main :

public class UserTest 
{ 
public static void main ( String args[] )
{
    int id, rg, cpf, cnpj, num, age, ctr=0;
    String name, name2, description, description2, email, phone, c, g, sex;
    Sensors sensors[];
    float cost, goal;


    Users user = new Users();
    while (ctr!=num)
    {
        user.sensors[ctr] = new Sensors();
        name2 = JOptionPane.showInputDialog("Nome do aparelho ligado ao sensor");
        description = JOptionPane.showInputDialog ("Localização do aparelho");
        user.sensors[ctr].setNome(name2);
        user.sensors[ctr].setDescription(description);
        ctr++;
    }
    /*exibir estatísticas*/
    user.stats(ctr);
}
}

But in both the method call and the total variable assignment, you are giving the illegal start of expression error. If anyone can help, I'm grateful.

    
asked by anonymous 11.07.2015 / 14:43

1 answer

3

The error is in your method stats

public void stats (int num)
{
    int i;
    float total=0, perc;
    for (i=0;i<num;i++)
    {
        total = total + sensors[i].statistics.getTotalConsumption(sensors[i].statistics.data[]);  //<--- não estás a indexar o array data[faltaAquiUmIndice]. Ou data não é um array
    }
}
    
11.07.2015 / 21:41