Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

In Java why we write public static void main(String args[])
why not main()?

Answer Posted / anjani kumar jha

Use of Public-----There is always only one main class that
is one file having only one main file. Since that main file
is used anywhere means might be in another package so there
is a public use of keyword that is public keyword is
required for main function

Static:-----Since compiler in java always look the main
function and when compiler always calls the main so main
class is loaded in first time call for that static keyword
is used.
you can use
1)public void main(String args[])
it compiles file but wont run\

2) void main(String args[])
it compiles file but wont run

3)void main(String args[])
it compiles file but wont run

Is This Answer Correct ?    87 Yes 37 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is meant by main method?

998


Is {a, n, d} a palindrome? If you are given a random string, is it a palindrome or not?

1051


Does apple use java?

891


What is binary search in java?

948


How do you convert bytes to character in java?

946


What is a byte string?

1055


Why do we need data structure in java?

1019


What do you mean by singleton class in java?

856


What is java algorithm?

881


What is n in java?

899


how can you take care of mutual exclusion using java threads? : Java thread

993


What are the different types of sorting in java?

933


What is the different between get and post?

906


What is a conditional statement explain with example?

964


What is native code?

1025