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.
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:
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.
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);
}
}
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.
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.
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);
}