Code example for Observable

Methods: addObserver

	private float temperature ;
	private float humidity;
	public CurrentConditionsDisplayUtil(Observable observable){
		this.observable = observable;
	public void display() { 
		// TODO Auto-generated method stub 
		System.out.println("Current Conditions:"+temperature +"F degrees and " + humidity +"%humidity");
	public void update(Observable obs, Object arg1) {
		// TODO Auto-generated method stub 
		if(obs instanceof WeatherDataUtil){
			WeatherDataUtil weatherDataUtil = (WeatherDataUtil)obs;
			this.temperature = weatherDataUtil.getTemperature();
			this.humidity = weatherDataUtil.getHumidity();
Experience pair programming with AI  Get Codota for Java