Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Register Tags Active Topics RSS Search Mark Forums Read

Sponsored Links



Explain main method in java

Software Development


Reply
 
Thread Tools Search this Thread
  #1  
Old 10-03-2010
Member
 
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.

Reply With Quote
  #2  
Old 10-03-2010
Member
 
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.
Reply With Quote
  #3  
Old 10-03-2010
Member
 
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);
  }
}
Reply With Quote
  #4  
Old 10-03-2010
Member
 
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.
Reply With Quote
  #5  
Old 10-03-2010
Member
 
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.
Reply With Quote
  #6  
Old 10-03-2010
Member
 
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);
  }
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: , , ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "Explain main method in java"
Thread Thread Starter Forum Replies Last Post
During bootup I get this error message Error invoking method: main (java.lang.string) Karsten M Windows Software 5 15-12-2010 07:18 PM
Why main method is static in java? MKAIF Software Development 5 06-03-2010 04:20 PM
Procedure to run Java program without main method Sheena_thakkar Software Development 3 26-11-2009 02:57 PM
Explain getAttribute method in jsp Otilio Software Development 3 25-11-2009 07:10 PM
What is method overriding and method overloading in java beelow Software Development 3 17-11-2009 08:20 AM


All times are GMT +5.5. The time now is 02:40 AM.