Results 1 to 6 of 6

Thread: Explain main method in java

  1. #1
    Join Date
    Mar 2010
    Posts
    202

    Explain main method in java

    Hello,
    I am very new to java and I have problem, so please help me. I wonder what is really the main method.
    Code:
    	Public static void hand(String[ ] Args) {
    		LinkedList l = new LinkedList( );
    System.out.System.out.println("Initialize the stack with these values:);
    
    	}
    I have a problem with the main method, i mean not really a problem I need an explanation on the main method in java. Thanks in advance.

  2. #2
    Join Date
    Nov 2009
    Posts
    446

    Re: Explain main method in java

    Hello,
    The main method is the entry point of every Java program. When launching a Java program with the command:
    Code:
    java ClassTest
    The JVM (Java Virtual Machine) is seeking a method whose signature is:
    Code:
    public static void hand(String[] args)
    and in order to run. If this method is absent, you get the error message that you were trying to run the class.

  3. #3
    Join Date
    Dec 2009
    Posts
    202

    Re: Explain main method in java

    Hello,
    What is the argument which is always String [] hand and it is equivalent to BEGIN END. Pascal.
    Just have a look at the following code
    Code:
    Public class Pic extends JPanel {
      private Image im;      
      
      Public Pic(String file) {
        im = new ImageIcon(getClass().getResource(file)).getImage();
        repaint(); 
      }  
     
      Public void paintComponent(Graphics grp) {
        great.paintComponent(grp);
        if (im == null) return;
        int wei = im.getWidth(this);  
        int hei = im.getHeight(this);
        boolean zoom = (wei> getWidth() | | hei> getHeight());
        if (zoom) grp.drawImage(im, 0, 0, GetWidth(), GetHeight(), this);
        else grp.drawImage(im, (getWidth()-wei)/2, (getHeight()-hei)/2, this);
      }
    }

  4. #4
    Join Date
    Nov 2009
    Posts
    347

    Re: Explain main method in java

    Hello,
    The parameters of the main method, it is actually one can pass arguments to the program during its launch, for example, if we consider the following program:
    Code:
    Public class Test{
         Public static void hand(String[] args){
                System.out.System.out.println(args[0]);
                System.out.System.out.println(args[1]);
         }
    }
    Hope you are clear with the concept.

  5. #5
    Join Date
    Nov 2009
    Posts
    343

    Re: Explain main method in java

    Hello,
    If it does not hand it runs is that it should be an applet: a GUI that builds itself an implicit hand (which only run one instance of the class). The class is a JPanel, to test you must do so in a GUI, or in hand building an interface with a Picture. If you need more information on this then you can visit the sun's official site and there you can find more detailed information on the same. I recommend you to do so study on the basics of the java programming language.

  6. #6
    Join Date
    Nov 2009
    Posts
    518

    Re: Explain main method in java

    Hello,
    If it is a applet then it will look some thing like this, take a look at the below code.
    Code:
      Public void paint(Graphics grp){
        s =new Picture(C:\\example.jpg ");
        s.setVisible(true);
        s.paintComponent(grp);
      }

Similar Threads

  1. Replies: 5
    Last Post: 15-12-2010, 07:18 PM
  2. Why main method is static in java?
    By MKAIF in forum Software Development
    Replies: 5
    Last Post: 06-03-2010, 04:20 PM
  3. Procedure to run Java program without main method
    By Sheena_thakkar in forum Software Development
    Replies: 3
    Last Post: 26-11-2009, 02:57 PM
  4. Explain getAttribute method in jsp
    By Otilio in forum Software Development
    Replies: 3
    Last Post: 25-11-2009, 07:10 PM
  5. What is method overriding and method overloading in java
    By beelow in forum Software Development
    Replies: 3
    Last Post: 17-11-2009, 08:20 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,711,638,274.30130 seconds with 17 queries