English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
UtilisationtoString()
La méthode convertit Short en chaîne de caractères. D'abord, prenons un type de données primitive courte et initialisons une valeur courte.
short myShort = 55;
Maintenant, incluons cette valeur dans l'objet Short suivant.
Short s = new Short(myShort);
UtilisationtoString()
Dans l'exemple complet ci-dessous, la méthode convertit le Short donné en chaîne de caractères.
public class Demo { public static void main(String []args) { short myShort = 55; Short s = new Short(myShort); System.out.println("Courte: ");+s); String myStr = s.toString(); System.out.println("Chaine: ");+myStr); } }
Résultat de la sortie
Courte: 55 Chaine: 55