⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 data.java

📁 这个文件里面包含了java设计模式的一些例子讲解
💻 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 + -