خرید بک لینک

Vote count: 0

I had seen a video where, main() can be run with in an enum. I am trying to do the same but it's not working.

Here is my code

public enum EnumMain {                             
   ABC, XYZ;                                       
   public static void main(String[] args) {        
     System.out.print("MIAN");                     
   }                                               
}

Output (The code compiles fine)
Error: Could not find or load main class EnumMain

I think this has something to do with the Java version, may be in Java 8, they are not allowing to run main() method from enum

asked 1 min ago

1 Answer

Vote count: 0

the main method is suppose to be placed inside a class an not enumerators...

public static void main(String[] args) {        
     System.out.print("MIAN");                     
   }   

answered 18 secs ago

برچسب: نویسنده: استخدام کار تاريخ: يکشنبه 16 خرداد 1395 ساعت: 16:02

صفحه بندی