English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
La méthode convertit une chaîne en octets. Pour commencer, nous allons en créer une.valueOf()
La méthode convertit une chaîne en octets. Pour commencer, nous allons en créer une.
String str = "65";
Maintenant, utilisez cettevalueOf()
La méthode convertit une chaîne en octets.
byte res = Byte.valueOf(str);
Voyons un exemple complet.
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); } }
Résultat de la sortie
String: 65 Byte: 65