-2

I am novice programming. I am using java. I have declared an array like this:

static String horario[];

later, in one method I want to use this array like this:

if(datos.get(z+3).contains("CET")) {
    horario[]=  (datos.get(z+3).split("CET"));
    mipartido.setHorario(horario[0]);
}

but it says that horario cannot be resolved to a type.

How can I use this variable?

Luiggi Mendoza
  • 85,076
  • 16
  • 154
  • 332
Elena
  • 181
  • 2
  • 12

1 Answers1

2

You shouldn't use [] unless you're assigning an element to a specific index of the array, for example: horario[0] = "abc";

So, since you're assigning the array, you should change:

horario[]=  (datos.get(z+3).split("CET"));

to:

horario =  (datos.get(z+3).split("CET"));
Nir Alfasi
  • 53,191
  • 11
  • 86
  • 129