Why ..we have to use this ? public static void ? please !

hi ...im ibrahim ..and im new here in java nd new in the forum too ...nd please i would like to know ...why
do we use the method
public static void main (String []args)
i mean why ..static nd why public ..why void ....why main ..nd why (string []args)
...why we use it ...always ....hopefully ..im looking for a very clear answer to this ...issue ..?
please help .......!

public - this is the visibility modifier (it means that the body method can be call by any outside method)
static - the method is a static instance of the class. Not sure what exactly it does though.
void - this is the return type. void means that the method returns nothing.
main - the name of the method. It can be anything.
"public static void main" - this is the main method where upon executing the Java program the Java Virtual Machine will try to locate this method within the specifies class to be executed. This is always the first one to run when executing a Java program. None of this word may be changed or the program cannot be run.

Similar Messages

  • Do i have to use this 'update'? I have serious work to do TODAY and i don't have time now to learn this. Thank you.

    I took a break for lunch and when I logged back on and my Mozilla home page was gone. I was in the middle of reading and printing forms for investment purposes; Very important to me right now. Do i have to use this update? Help please.

    It is always recommended to use the latest release, because earlier releases have publicly disclosed security vulnerabilities.
    Could you be more specific about the problem you're running into with Firefox 31?
    Some things that might help:
    * If you like using the classic menu bar, you can turn that one using any of these:
    ** right-click a blank area of the tab bar
    ** right-click the "+" button on the tab bar
    ** tap the Alt key > View > Toolbars
    ** "3-bar" menu button > Customize > Show/Hide Toolbars
    * If you liked using the orange Firefox button, I have a page showing where those commands moved to in the "3-bar" menu: http://www.jeffersonscher.com/res/menu/comp.php
    * To comprehensively revamp the user interface, you can use this extension: https://addons.mozilla.org/firefox/addon/classicthemerestorer/

  • Why can't created an object in the "public static void main(String args[])"

    Example:
    public Class Exp {
    public static void main(String args[])
    new Exp2();-------------> To Occur Error
    Class Exp2 {
    public Exp2()

    You can't create an inner class within main, because
    it is a static method. Inner classes can only be
    created by true class methods.This is not correct. You can create an inner class object in a static method. You just have to specify an outer class object that the inner class object should be created within:
    Exp2 exp2 = new Exp().new Exp2();

  • Why the singleton pattern used rather than static things?

    class Single
        private Single() {}
        private void print() { System.out.println("Foo~"); }
        private static Single one = new Single();
        public static void print() { one.print(); }
    class Stat
        public static void print() { System.out.println("Foo~"); }
    }What's the different?? What is the benefit of the singleton one?

    There is no practical difference - because, in fact, that is not the singleton pattern!
    A singleton would look like:
    class Singleton {
        private Singleton() {}
        public void print() { System.out.println("Foo~"); }
        private static Singleton instance = new Singleton();
        public static Singleton getInstance() { return instance; }
    }The benefit of this pattern is, that your client code doesn't have to know that there is only one instance (getInstance could return another instance for every call) or of which actual type it is (getInstance could return an instance of any Subclass of Singleton).
    See http://c2.com/cgi/wiki?SingletonPattern for more information on the pattern.

  • I bought my i pod touch from us but i live in india .i have been using this from many days fr just a few days before something went wrong with it and the date and time has changed what do i do?

    i bought my i pod touch from us but i live in india .i have been using this from many days fr just a few days before something went wrong with it and the date and time has changed what do i do?

    Have you went to Settings>General Time&Date and correct the time.  Make sure the time zone is correct too.  Also go to Settings>General>Inernational and make sure the Gergorian calender is selected.

  • Since updating to LR5.5 it crashes about every 5-10 images while working in the development module. Computer is PC Windows 7 Home Premium. I have been using this computer for several years with zero problems. Is this related to the updating? What is the f

    Since updating to LR5.5 it crashes about every 5-10 images while working in the development module. Computer is PC Windows 7 Home Premium. I have been using this computer for several years with zero problems. Is this related to the updating? What is the fix?

    Do you get an error message? If so, what does it say?
    Do you get a Blue Screen?
    Does something else happen?

  • Why I have to use -s after sqlplus in a shell script?

    Hi,
    sqlplus -s "/as sysdba" is in my script. But why I have to use -s?

    Hi
    Run sqlplus /? from your command line and you see that option means silent mode, i.e. suppression of SQL*Plus banner, echo's and prompts.
    Bye Auke
    Message was edited by:
    aukequist

  • I keep getting Error 150:30, What should I do? I have not used this program in over a year.

    I keep getting Error 150:30, what should I do? I have not used this program in over a year.

    Well, what program? Anyway, try this:
    Error "Licensing has stopped working"
    Mylenium

  • It won't let me drag an effect from the browser all of a sudden. I have always been able to do before. I am using effects from favorites bin and when I try to drag it, it won't move. I have never had this problem before. Please help.

    It won't let me drag an effect from the browser all of a sudden. I have always been able to do before. I am using effects from favorites bin and when I try to drag it to the timeline, it won't move. I have never had this problem before. Please help.
    P.S. I have tried other effects including transitions and it still won't let me drag.

    Wow that was really quick, thank you so much.  Im not sure at all which version it was because i said it was around 4 years ago he bought it.  I know it isn't under his username, since he's a PC person (ugh) so i know its probably registered to one of our actual names.  isn't there some way to look it up since we did register it, because I'm not even sure where the disks are from when we bought it (we've moved a lot and also have two storage lockers, i know i would have kept it with other disks) but my cd rom drive is actually broken on my computer as well ( i think it got stepped on and is now squished and won't eject or run disks.)
    So is there anyway they can look up that its registered to one of our names since we did register it when we bought and installed it, or do i really have to find the disk with some sort of proof of purchase (i know there would be no receipt after all this time)
    either way, ill do what you suggested to the best of my abilities and thank you so much for answering my questions, i can't even open the program as its incompatible and find out the info from that) so I'm in a bit of a pickle and your response was so thorough and it didn't seem to be posted long enough to even write a well researched response, thanks, all the best,
    sarucia

  • HT5312 I tried to download a song but Apple is saying I have not used this computer before

    I tried to download a song but Apple is saying I have not used this computer before and that in order to downloas the song I need to "verify my identity" by answering some securiry qiestions.
    This is wrong because I have downloaded scored of songs on this computer but I answered the security queations anyway, only to be told I have answered incorrectly.
    But the anwers were correct.
    Anyone any ideas what might be happening?
    Thank you.

    Have you re-installed or updated the OS on that computer ? There have also been the occasional post from other people when it hasn't been the first purchase.
    If it's not accepting your answers then the page that you posted from has instructions for how to reset them i.e. if you have a rescue email address (which is not the same thing as an alternate email address) set up on your account then steps 1 to 5 half-way down that page should give you a reset link.
    If you don't have a rescue email address (you won't be able to add one until you can answer your questions) then you will need to contact iTunes Support / Apple in your country to get the questions reset.
    Contacting Apple about account security : http://support.apple.com/kb/HT5699
    When they've been reset (and if you don't already have a rescue email address) you can then use the steps half-way down the HT5312 page that you posted from to add a rescue email address for potential future use

  • Hi, i was recently on an IOS 7 update before it's release and downloaded it from the web and i just got this message saying that my device is not registered as a part of the iphone developer. i have been using this for about 2 months now. what is a fix?

    hi, i was recently on an IOS 7 update before it's release and downloaded it from the web and i just got this message saying that my device is not registered as a part of the iphone developer. i have been using this for about 2 months now. what is a fix?

    Were you running iOS 7 beta?  If so, as a developer you need to log into the Developer forum for assistance.
    Not a developer and running iOS 7 beta?  <edited by host>

  • How to call java with public static void main(String[] args) throws by jsp?

    how do i call this from jsp? <%spServicelnd temp = new spServicelnd();%> does not work because the program has a main. can i make another 2nd.java to call this spServiceInd.java then call 2nd.java by jsp? if yes, how??? The code is found below...
    import java.net.MalformedURLException;
    import java.io.IOException;
    import com.openwave.wappush.*;
    public class spServiceInd
         private final static String ppgAddress = "http://devgate2.openwave.com:9002/pap";
         private final static String[] clientAddress = {"1089478279-49372_devgate2.openwave.com/[email protected]"};
    //     private final static String[] clientAddress = {"+639209063665/[email protected]"};
         private final static String SvcIndURI = "http://devgate2.openwave.com/cgi-bin/mailbox.cgi";
         private static void printResults(PushResponse pushResponse) throws WapPushException, MalformedURLException, IOException
              System.out.println("hello cze, I'm inside printResult");
              //Read the response to find out if the Push Submission succeded.
              //1001 = "Accepted for processing"
              if (pushResponse.getResultCode() == 1001)
                   try
                        String pushID = pushResponse.getPushID();
                        SimplePush sp = new SimplePush(new java.net.URL(ppgAddress), "SampleApp", "/sampleapp");
                        StatusQueryResponse queryResponse = sp.queryStatus(pushID, null);
                        StatusQueryResult queryResult = queryResponse.getResult(0);
                        System.out.println("Message status: " + queryResult.getMessageState());
                   catch (WapPushException exception)
                        System.out.println("*** ERROR - WapPushException (" + exception.getMessage() + ")");
                   catch (MalformedURLException exception)
                        System.out.println("*** ERROR - MalformedURLException (" + exception.getMessage() + ")");
                   catch (IOException exception)
                        System.out.println("*** ERROR - IOException (" + exception.getMessage() + ")");
              else
                   System.out.println("Message failed");
                   System.out.println(pushResponse.getResultCode());
         }//printResults
         public void SubmitMsg() throws WapPushException, IOException
              System.out.println("hello cze, I'm inside SubmitMsg");          
              try
                   System.out.println("hello cze, I'm inside SubmitMsg (inside Try)");                         
                   //Instantiate a SimplePush object passing in the PPG URL,
                   //product name, and PushID suffix, which ensures that the
                   //PushID is unique.
                   SimplePush sp = new SimplePush(new java.net.URL(ppgAddress), "SampleApp", "/sampleapp");
                   //Send the Service Indication.
                   PushResponse response = sp.pushServiceIndication(clientAddress, "You have a pending Report/Request. Please logIn to IRMS", SvcIndURI, ServiceIndicationAction.signalHigh);
                   //Print the response from the PPG.
                   printResults(response);
              }//try
              catch (WapPushException exception)
                   System.out.println("*** ERROR - WapPushException (" + exception.getMessage() + ")");
              catch (IOException exception)
                   System.out.println("*** ERROR - IOException (" + exception.getMessage() + ")");
         }//SubmitMsg()
         public static void main(String[] args) throws WapPushException, IOException
              System.out.println("hello cze, I'm inside main");
              spServiceInd spsi = new spServiceInd();
              spsi.SubmitMsg();
         }//main
    }//class spServiceInd

    In general, classes with main method should be called from command prompt (that's the reason for main method). Remove the main method, put the class in a package and import the apckage in your jsp (java classes should not be in the location as jsps).
    When you import the package in jsp, then you can instantiate the class and use any of it's methods or call the statis methods directly:
    <%
    spServiceInd spsi = new spServiceInd();
    spsi.SubmitMsg();
    %>

  • How can i pass the values to method public static void showBoard(boolean[][

    I need x and y to pass to the method
    public static void showBoard(boolean[][] board
    i am very confused as to why its boolean,i know its an array but does that mean values ar true or false only?Thanks
    import java.util.Random;
    import java.util.Scanner;
    public class Life1
         public static void main(String[] args)
              int x=0;
              int y=0;
              Scanner keyIn = new Scanner(System.in);
              System.out.println("Enter the first dimension of the board : ");
              x = keyIn.nextInt();
              System.out.println("Enter the second dimension of the board : );
              y = keyIn.nextInt();
              boolean[][] board = new boolean[x][y];
              fillBoard(board);
              showBoard(board);
              //Ask the user how many generations to show.
              board = newBoard(board);
              showBoard(board);
         //This method randomly populates rows 5-9 of the board
         //Rewrite this method to allow the user to populate the board by entering the
         //coordinates of the live cells.  If the user requests that cell 1, 1 be alive,
         //your program should make cell 0,0 alive.
         public static void fillBoard(boolean[][] board)
              int row, col, isAlive;
              Random picker = new Random();
              for(row = 4; row < 9; row++)
                   for(col = 4; col < 9; col++)
                        if (picker.nextInt(2) == 0)
                          board[row][col] = false;
                        else
                          board[row][col] = true;
         //This method displays the board
         public static void showBoard(boolean[][] board)
              int row, col;
              System.out.println();
              for(row=0; row < x; row++)
                   for(col=0; col<y; col++)
                        if (board[row][col])
                             System.out.print("X");
                        else
                             System.out.print(".");
                   System.out.println();
              System.out.println();
         //This method creates the next generation and returns the new population
         public static boolean[][] newBoard(boolean[][] board)
              int row;
              int col;
              int neighbors;
              boolean[][] newBoard = new boolean[board.length][board[0].length];
              makeDead(newBoard);
              for(row = 1; row < board.length-1; row++)
                   for(col = 1; col < board[row].length-1; col++)
                        neighbors = countNeighbors(row, col, board);
                        //make this work with one less if
                        if (neighbors < 2)
                             newBoard[row][col]=false;
                        else if (neighbors > 3)
                             newBoard[row][col] = false;
                        else if (neighbors == 2)
                             newBoard[row][col]= board[row][col];
                        else
                             newBoard[row][col] = true;
              return newBoard;
         //This method counts the number of neighbors surrounding a cell.
         //It is given the current cell coordinates and the board
         public static int countNeighbors(int thisRow, int thisCol, boolean[][] board)
              int count = 0;
              int row, col;
              for (row = thisRow - 1; row < thisRow + 2; row++)
                   for(col = thisCol - 1; col < thisCol + 2; col++)
                     if (board[row][col])
                          count++;
              if (board[thisRow][thisCol])
                   count--;
              return count;
         //This method makes each cell in a board "dead."
         public static void makeDead(boolean[][] board)
              int row, col;
              for(row = 0; row < board.length; row++)
                   for(col = 0; col < board[row].length; col++)
                        board[row][col] = false;
    }

    this is what im workin with mabey you can point me in the right directionimport java.util.Random;
    /* This class creates an application to simulate John Conway's Life game.
    * Output is sent to the System.out object.
    * The rules for the Life game are as follows...
    * Your final version of the program should explain the game and its use
    * to the user.
    public class Life
         public static void main(String[] args)
              //Allow the user to specify the board size
              boolean[][] board = new boolean[10][10];
              fillBoard(board);
              showBoard(board);
              //Ask the user how many generations to show.
              board = newBoard(board);
              showBoard(board);
         //This method randomly populates rows 5-9 of the board
         //Rewrite this method to allow the user to populate the board by entering the
         //coordinates of the live cells.  If the user requests that cell 1, 1 be alive,
         //your program should make cell 0,0 alive.
         public static void fillBoard(boolean[][] board)
              int row, col, isAlive;
              Random picker = new Random();
              for(row = 4; row < 9; row++)
                   for(col = 4; col < 9; col++)
                        if (picker.nextInt(2) == 0)
                          board[row][col] = false;
                        else
                          board[row][col] = true;
         //This method displays the board
         public static void showBoard(boolean[][] board)
              int row, col;
              System.out.println();
              for(row=0; row < 10; row++)
                   for(col=0; col<10; col++)
                        if (board[row][col])
                             System.out.print("X");
                        else
                             System.out.print(".");
                   System.out.println();
              System.out.println();
         //This method creates the next generation and returns the new population
         public static boolean[][] newBoard(boolean[][] board)
              int row;
              int col;
              int neighbors;
              boolean[][] newBoard = new boolean[board.length][board[0].length];
              makeDead(newBoard);
              for(row = 1; row < board.length-1; row++)
                   for(col = 1; col < board[row].length-1; col++)
                        neighbors = countNeighbors(row, col, board);
                        //make this work with one less if
                        if (neighbors < 2)
                             newBoard[row][col]=false;
                        else if (neighbors > 3)
                             newBoard[row][col] = false;
                        else if (neighbors == 2)
                             newBoard[row][col]= board[row][col];
                        else
                             newBoard[row][col] = true;
              return newBoard;
         //This method counts the number of neighbors surrounding a cell.
         //It is given the current cell coordinates and the board
         public static int countNeighbors(int thisRow, int thisCol, boolean[][] board)
              int count = 0;
              int row, col;
              for (row = thisRow - 1; row < thisRow + 2; row++)
                   for(col = thisCol - 1; col < thisCol + 2; col++)
                     if (board[row][col])
                          count++;
              if (board[thisRow][thisCol])
                   count--;
              return count;
         //This method makes each cell in a board "dead."
         public static void makeDead(boolean[][] board)
              int row, col;
              for(row = 0; row < board.length; row++)
                   for(col = 0; col < board[row].length; col++)
                        board[row][col] = false;
    }

  • Error: Sorry! We could not complete the transaction using this payment method. Please contact support.

    I am everytime getting the following error
    Sorry! We could not complete the transaction using this payment method. Please contact support.
    I have put my 2 credit card information with Microsoft. I tried calling 2 times the customer support but it was a pathetic response. In a single call I talked to 4 customer support officers and everybody passed on the call to the next without resolving the
    problem, and without telling the next officer what is my issue!! they just passed on the phone call to avoid me!!
    It is really frustrating that neither Microsoft is provide a good support (it was hard for them to understand my issue, in fact one of the support guy did not even know spelling of Azure.. he/she was saying it assure!!! and One of the guy told me that I
    cannot use credit card outside US and Canada. then why you call yourself global???
    So Microsoft you have a few things to do as your homework.
    1. Your support is pathetic, frustrating and requires better people out there who know about your products, so train them first!
    2. You got my 2 credit cards information which I see at subscriptions for Windows Azure, please remove both of them if you cannot provide a good support and subscription.
    3. Learn from other cloud providers, AWS will otherwise kill your business.
    Regards
    Kajal
    Kajal Sinha

    Hi Kajal,
    Sincerely apologize for this inconvenience, for billing & account issue, usually we need to contact the support team by creating a support ticket at
    http://www.windowsazure.com/en-us/support/contact/. Or if that doesn't work because you don't have an active subscription you will need to contact general customer support to have them create
    a support ticket for you 
    http://support.microsoft.com/gp/customer-service-phone-numbers?wa=wsignin1.0).
    If above support channels don't work, at your convenient, could you please send an email to me: dxu at microsoft.com with kindly providing your:
    Name
    Email address
    Phone number 
    We will provide help via emails. Thank you.
    Best Regards,
    Ming Xu
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • Public static void vs. public static int

    hey java_experts,
    we're learning arrays and i was just wondering whats the difference between public static void vs. public static int

    hi i want to do java mail but i am new in this field
    so please suggest me how i have to get help for the
    java mailNext time start your own thread.
    Google for Java mail tutorial.

Maybe you are looking for

  • SAP BI Roadmap

    Hi All, Wishing you a very happy New Year. Has anyone prepared BI roadmap or build SAP BI practice  ? If so can you please share with me. I am looking for some best practices/tips. Thanks Sonya

  • Convert and combine many image files into a pdf file?

    I have about 250 png and jpg files in a directory, and would like to convert and combine them into a pdf file. I wonder what steps to do that in Acrobat Adobe 9 in Windows? Requirements are: They are named in the order of 0000.png, 0001.jpg, ..., 025

  • Panel Tabbed refresh problem

    I have created sample.jsff and added three tabs using Pannel Tabbed from the ADF faces Layout. Each tab is having Table component from the ADF common components where I can input text. After inputting values in the first tab and submit, the values ar

  • Apple pages. Is there a 'Merge' Function

    As all you Mac users will know, (Clarisworks-AppleWorks), has a fine database option for use when merging documents. I need to send a same letter to a number of customers. Is this possible in 'Pages' or do I have to revert back to 'AppleWorks'? Any h

  • Sharing a shared drive

    I have a desktop computer connected to a server with a fiber connection.  My laptop doesn't have a fiber card. Is there anyway for me to share the server drives from my desktop to my laptop computer?