在 Java 中将字符串转换为短数字
在 Java 中使用 Short.parseShort() 方法将字符串转换为短数字。
假设我们的字符串如下所示。
String str = “76”;
现在,parseShort() 方法将字符串转换为短数字。
byte val = Byte.parseByte(str);
示例
public class Demo { public static void main(String[] args) { String str = "76"; short val = Short.parseShort(str); System.out.println(val); } }
输出
76
广告
数据结构
网络
RDBMS
操作系统
Java
iOS
HTML
CSS
Android
Python
C 编程
C++
C#
MongoDB
MySQL
Javascript
PHP