Let the Interface in Java become your C ++ enum type.

xiaoxiao2021-03-05  22

First learn C / C to learn Java friends may think that Java is not enorma type is very inconvenient. This problem can be solved by interface:

For example, define an interface:

Public Interface Animal

{

INT DOG = 1, CAT = 2, Tiger = 3, Snake = 4;

}

Public Class Test Implements Animal

{

Public test ();

Public Boolean IsDog (int Atemal)

{

Return (Animal == DOG)? TRUE: FALSE;

}

}

转载请注明原文地址:https://www.9cbs.com/read-39031.html

New Post(0)