前言
月是一轮明镜,晶莹剔透,代表着一张白纸(啥也不懂)
央是一片海洋,海乃百川,代表着一块海绵(吸纳万物)
泽是一柄利剑,千锤百炼,代表着千百锤炼(输入输出)
月央泽,学习的一种过程,从白纸->吸收各种知识->不断输入输出变成自己的内容
希望大家一起坚持这个过程,也同样希望大家最终都能从零到零,把知识从薄变厚,再由厚变薄!
/**
* An object to which <tt>char</tt> sequences and values can be appended. The
* <tt>Appendable</tt> interface must be implemented by any class whose
* instances are intended to receive formatted output from a {@link
* java.util.Formatter}.
*
* <p> The characters to be appended should be valid Unicode characters as
* described in <a href="Character.html#unicode">Unicode Character
* Representation</a>. Note that supplementary characters may be composed of
* multiple 16-bit <tt>char</tt> values.
*
* <p> Appendables are not necessarily safe for multithreaded access. Thread
* safety is the responsibility of classes that extend and implement this
* interface.
*
* <p> Since this interface may be implemented by existing classes
* with different styles of error handling there is no guarantee that
* errors will be propagated to the invoker.
*
* @since 1.5
*/
根据源码注释我们可以知道:
- 实现该接口的类是为了添加字符序列和值
- 如果某个类的实例打算接收Formatter的格式化输出,那么必须实现该接口
- 实现该接口之后,对于多线程的时候,会导致线程安全问题
- 如果这个接口必须实现,那么无法保证一些错误的方式会传递给调用者
二.Appendable接口的方法:
/**
* 添加字符序列到尾部
*/
Appendable append(CharSequence csq) throws IOException;
/**
* 添加指定字符序列的子序列
*/
Appendable append(CharSequence csq, int start, int end) throws IOException;
/**
* Appends the specified character to this <tt>Appendable</tt>.
*添加字符到尾部
*/
Appendable append(char c) throws IOException;
很简单的三个方法.
四.总结
月央泽,继续加油!