📄 data.java
字号:
package com.javapatterns.observer.mvc;
/*
* This example is from javareference.com
* for more information visit,
* http://www.javareference.com
*/
//import statements
import java.util.*;
/**
* Data.java
* This class demonstrates the use of Observer Pattern
* This class represents the Data Object and extends the Observable
*
* @author Rahul Sapkal(rahul@javareference.com)
*/
public class Data extends Observable
{
private int m_value;
//Constructor
public Data(int value)
{
m_value = value;
}
//set Data
public void setData(int value)
{
m_value = value;
//Make sure to set the hasChanged flas to true
//otherwise the notifyObservers() call will not
//notify the Observers
setChanged();
}
//get Data
public int getData()
{
return m_value;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -