English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
使用してvalueOf()
メソッドを使用して文字列をバイトに変換します。まず、一例を示しましょう。
String str = "65";
今、このvalueOf()
メソッドは文字列をバイトに変換します。
byte res = Byte.valueOf(str);
完全な例を見てみましょう。
public class Demo { public static void main(String[] args) { String str = "65"; System.out.println("String: "+str); byte res = Byte.valueOf(str); System.out.println("Byte: "+res); } }
出力結果
String: 65 Byte: 65