class User(val age: Int, val name: String) {
override def toString: String = s"[age = $age, name = $name]"
}
这样在打印对象的时候打印的就不是地址值了.
class User(val age: Int, val name: String) {
override def toString: String = s"[age = $age, name = $name]"
}
这样在打印对象的时候打印的就不是地址值了.
上一篇:HBase数据模型介绍
下一篇:Scala 匿名内部类
gorm自定义日志格式,可实现慢sql自定义打印
之所以专门重写这两种方法,说明这两种方法的重要性,相对来说equals方法更为重要,虽然在一些编译器应该都可以自动实现,但是掌握这种方两法还是很有必要的。一、重写toString方法1、java库中的源代码:
举报文章
请选择举报类型
补充说明
0/200
上传截图
格式支持JPEG/PNG/JPG,图片不超过1.9M