English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
まず、短い基本型を作成し、値を割り当てます。
short val = 30;
今、Short オブジェクトを作成し、上記の short 型に設定します。
Short myShort = new Short(val);
以下は、Short コンストラクタを使用して short 基本型を Short オブジェクトに変換する完全な例です。
public class Demo { public static void main(String[] args) { short val = 30; Short myShort = new Short(val); System.out.println(myShort); } }
出力結果
30