ابدأ بالتواصل مع الأشخاص وتبادل معارفك المهنية

أنشئ حسابًا أو سجّل الدخول للانضمام إلى مجتمعك المهني.

متابعة

What happens if I declare main method as private in Java?

user-image
تم إضافة السؤال من قبل Karimuddin Syed , Software Developer , SCHIMATIC TECHNOLOGIES PVT LTD
تاريخ النشر: 2013/06/20
Javed Khan
من قبل Javed Khan , Senior Programmer Analyst , Barclays Technology

Your main will become like any other private method.
Since it is private it cannot be invoked and hence the application cannot be called.

Zabeer Sultan
من قبل Zabeer Sultan , Senior Technical Lead , Happiestminds

Only the main method which is public can be invoked by the JVM.
So a private main method will be treated as any other method which eventually needs to be invoked from a public main method.

Mohammed Ameen
من قبل Mohammed Ameen , Java Developer , TATA Consultancy Services Limited (TCSL)

The Program compiles properly but at the runtime it will give "Main method not public" message.

himanshu mittal
من قبل himanshu mittal

it will compile fine but at run time it will give you an error "no such method found".

المزيد من الأسئلة المماثلة

هل تحتاج لمساعدة في كتابة سيرة ذاتية تحتوي على الكلمات الدلالية التي يبحث عنها أصحاب العمل؟