English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
Utilizzando ilvalueOf()
metodo per convertire una stringa in byte. Prima di tutto, diamo un'occhiata a una sequenza.
String str = "65";
Ora, utilizziamo ilvalueOf()
Il metodo converte una stringa in byte.
byte res = Byte.valueOf(str);
Vediamo un esempio completo.
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); } }
Risultato di output
String: 65 Byte: 65