首页
学习
活动
专区
圈层
工具
发布
社区首页 >专栏 >String与其他类型之间转换

String与其他类型之间转换

作者头像
johnhuster的分享
发布2022-03-28 13:43:46
发布2022-03-28 13:43:46
4360
举报
文章被收录于专栏:johnhusterjohnhuster

写这篇博客的初衷是:今天百度查了下char转String的问题,一位老兄的博客里面写着调用char类型的toString方法。

java新版JDK里面关于一些常见类型转String的静态方法:

static String

valueOf(boolean b) Returns the string representation of the boolean argument.

static String

valueOf(char c) Returns the string representation of the char argument.

static String

valueOf(char[] data) Returns the string representation of the char array argument.

static String

valueOf(char[] data, int offset, int count) Returns the string representation of a specific subarray of the char array argument.

static String

valueOf(double d) Returns the string representation of the double argument.

static String

valueOf(float f) Returns the string representation of the float argument.

static String

valueOf(int i) Returns the string representation of the int argument.

static String

valueOf(long l) Returns the string representation of the long argument.

static String

valueOf(Object obj) Returns the string representation of the Object argument.

其实了解java基础的人都应该知道toString是所有Object对象的一个方法,但是char属于基本类型,不属于类范畴!!

估计这位老兄说的应该是char类型的包装器类型Character的toString方法吧,这个方法的用法如下,一看便明白:

static StringtoString(char c)

Returns a String object representing the specified char.

本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2015/08/28 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档