Quantcast
Channel: 質問!ITmedia 新着質問(Java/253)
Viewing all articles
Browse latest Browse all 2439

java enum

$
0
0
エラー内容 int cannot be dereferenced 何が原因でエラーになっているのですか? import java.util.*; enum light{ red,yellow,blue } class m1{ public static void main(String[] args){ int light; Scanner ss = new Scanner(System.in); System.out.println("整数値を入力 : "); int i = ss.nextInt(); if(i == light.red.ordinal()){ System.out.println("信号は赤色です"); } else if(i == light.yellow.ordinal()){ System.out.println("信号は黄色です"); } else if(i == light.blue.ordinal()){ System.out.println("信号は青色です"); } } }

Viewing all articles
Browse latest Browse all 2439

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>