Static fields and arrays
807597Jun 28 2005 — edited Jun 28 2005I'm putting together my first 'structure' that I want to use as an array. Currently the structure (or should I be saying class?) will only be holding variables. It looks like below:
package weather;
public class WeatherObject
{
public WeatherObject(){}
// Date and Time
static String datLastUpdate = "N/A";
static String datDay = "";
static String datDate = "";
static String datMonth = "";
}
However when I try to access it with the code below:
WeatherObject[] wo = new WeatherObject[10];
int n = 0;
wo[n].datLastUpdate ="x";
I get the following warnings:
The static field WeatherObject.datLastUpdate should be accessed in a static way
I've tried removing 'static', but that just crashed the program. Can anyone tell me what I'm doing wrong. The program works OK with the warnings there, but in the past warnings I've ignored have always come back to bite me.
Thanks