[JAVA]数组转换成字符串
来源:互联网 发布:鲁能泰山 网络直播 编辑:程序博客网 时间:2024/05/16 11:31
所有类都继承自Object类,Object里有一个方法就是toString(),那么所有的类创建的时候,都有一个toString的方法。
Object类中的toString()方法的源代码如下:
/** * Returns a string representation of the object. In general, the * {@code toString} method returns a string that * "textually represents" this object. The result should * be a concise but informative representation that is easy for a * person to read. * It is recommended that all subclasses override this method. * <p> * The {@code toString} method for class {@code Object} * returns a string consisting of the name of the class of which the * object is an instance, the at-sign character `{@code @}', and * the unsigned hexadecimal representation of the hash code of the * object. In other words, this method returns a string equal to the * value of: * <blockquote> * <pre> * getClass().getName() + '@' + Integer.toHexString(hashCode()) * </pre></blockquote> * * @return a string representation of the object. */ public String toString() { return getClass().getName() + "@" + Integer.toHexString(hashCode()); }
因为数组类中并没有对toString方法的重写(override),仅仅是重载(overload)为类的静态方法(参见java.util.Arrays)。所以,数组直接使用toString()的结果也是[类型@哈希值]。
所以数组转为字符串应写成:Arrays.toString(A)
参考资料:http://www.cnblogs.com/ningvsban/p/3955483.html
0 0
- [JAVA]数组转换成字符串
- java数组转换字符串
- java实现字符数组转换成字符串
- Java将字节数组转换成字符串
- java将字符串根据分隔符转换成字符串数组
- java中如何将字符串数组转换成字符串
- Java中如何将“字符串数组”转换成“字符串”
- 数组转换成字符串
- Java 字符串数组转换为List数组
- Java 字符串转换为字符串数组
- java中字符串转换为字符串数组
- java中,如何将一个字节数组转换成字符串?
- java基础将一个int数组转换成一个字符串
- java中如何将数组 转换成一个字符串
- java 数组转换成字符串 类似 js array的join
- 将数组转换成字符串
- 字符串转换成int数组
- 字符串转换成int[]数组
- LeetCode 524. Longest Word in Dictionary through Deleting
- LeetCode 530. Minimum Absolute Difference in BST
- java线程实现的三种方式
- hibernate中的update()和saveOrUpdate()的区别,session的load()和get()的区别。
- opencv学习笔记(二十九)绘制一个RGB三色直方图
- [JAVA]数组转换成字符串
- Linux gcc编译器
- Macos系统下PATH环境变量的配置方法
- 蓝桥杯 ALGO-98 算法训练 数位分离
- String,StringBuffer与StringBuilder之间区别
- hadoop hbase 问题 及 简单 案例
- python基础学习-网络学习
- python搜索包的路径
- netstat命令