Use private access control: - Java Object Oriented Design

Java examples for Object Oriented Design:Access Level

Description

Use private access control:

Demo Code

class Logger { 
        private String format; 

        public String getFormat () { 
            return this.format; 
        } /*w ww  .j  av a 2  s.c om*/

        public void setFormat (String fmt) { 
            if  (  (fmt.equals("common"))  ||  (fmt.equals("combined")) ) { 
                this.format = fmt; 
            } 
        } 
    }

Related Tutorials