Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
- package com.mycompany.ja10.model;
- /**
- *
- * @author Admin
- */
- public class Test2 {
- public static void printColor(MyColor c){
- System.out.println("c=" + c);
- }
- //
- public static void printInfo(MyColor c){
- System.out.println("c=" + c);
- // switch
- switch (c) {
- case BLUE:
- System.out.println("Синий цвет");
- break;
- case RED:
- System.out.println("Красный цвет");
- break;
- default:
- System.out.println("нет совпадений");
- }
- }
- //
- public static void main(String[] args) {
- MyColor c = MyColor.BLUE;
- printColor(MyColor.BLUE);
- // получаем все константы
- for(MyColor color: MyColor.values()){
- System.out.println("color=" + color);
- }
- System.out.println("c.name()=" + c.name());
- printInfo(MyColor.GREEN);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement