为什么没有String.valueOf(short a); [英] Why is there no String.valueOf(short a);

查看:116
本文介绍了为什么没有String.valueOf(short a);的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我必须将其转换为字符串,唯一的方法是用它连接一个空字符串,这是正确的方法吗?

I had to cast short to a string and the only way I could do it was to concatenate an empty string with it, is this the right way?

PS ,为什么没有 String.valueOf(short a);

PS, why is there no String.valueOf(short a);

推荐答案

由于JDK的创建者认为不需要它。

Because the creators of the JDK didn't think that it is needed.

简短地说,您可以简单地调用 String.valueOf(int)

Given a short you can simply call String.valueOf(int).

请注意,即使 Short.toString(short)也被实现为 return Integer.toString((int)s,10);

Note that even Short.toString(short) is implemented as return Integer.toString((int)s, 10);

这篇关于为什么没有String.valueOf(short a);的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆