Solved

Need Clarification

Posted on 2004-08-11
15
203 Views
Last Modified: 2010-03-31
What is the difference between :
public static void main(String args[])
and
static public void main(String[] s)

Why we are not using String args[] in the static public void main as well?
0
Comment
Question by:lordiano
  • 6
  • 4
  • 3
  • +1
15 Comments
 
LVL 15

Expert Comment

by:Javatm
ID: 11779339
Technically speaking >
public static void main(String args[])

Is the normal way of declaring a public access main method and its is the normal thing than  :
static public void main(String[] s)

Hope that helps . . .
Javatm
0
 

Author Comment

by:lordiano
ID: 11779346
Is there any difference between String args[] and String[] s
aint they both just gonna be pointer object to string array?
0
 
LVL 15

Expert Comment

by:Javatm
ID: 11779387
Here are the meanings : public static void main(String args[])

public :
This method can be accessed from outside the class

static :
This method does not require that an object of the class exists. static methods are sort of like global methods,
they are always available, but you need to use the class name to get them

void : no return value

main(String args[]) :
main() will be passed an array of Strings correspondig to any command line parameter values.
0
 
LVL 15

Expert Comment

by:Javatm
ID: 11779396
> aint they both just gonna be pointer object to string array?

Yes thats correct ! both are array strings.
0
 
LVL 92

Expert Comment

by:objects
ID: 11779454
both are the same
0
 
LVL 4

Assisted Solution

by:funnyveryfunny
funnyveryfunny earned 25 total points
ID: 11779762
public static void main(String[] args) ==> it's a predefined method signature.
0
 

Author Comment

by:lordiano
ID: 11779963
Thanks for reply,
I understand the public, static and void..etc
but what i dont get is
can we use

static public void main(String s[])

instead of

static public void main(String[] s)

I am increasing the point because its more questions that i originally posted
0
Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

 
LVL 15

Expert Comment

by:Javatm
ID: 11779969
I think you mean this :

public static void main(String args[]) and static public void main(String[] s) ?

Yes you can . . .
0
 
LVL 15

Accepted Solution

by:
Javatm earned 150 total points
ID: 11779972

Or this :

static public void main(String s[]) instead of static public void main(String[] s) ?

Yes you still can . . .
0
 

Author Comment

by:lordiano
ID: 11779983
so it does not make any difference then?
whether i have (String s[]) or (String[] s)
0
 
LVL 92

Assisted Solution

by:objects
objects earned 25 total points
ID: 11780005
no
0
 

Author Comment

by:lordiano
ID: 11780015
thank you for everyone that helped
0
 
LVL 92

Expert Comment

by:objects
ID: 11780078
0
 
LVL 4

Expert Comment

by:funnyveryfunny
ID: 11783770
:-)
0
 
LVL 15

Expert Comment

by:Javatm
ID: 11788485
=-) Always Glad 2 Help . . .

http://freewebs.com/cube-j
Friend : Javatm
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now