wood burning stoves 2.0*
The moose likes Beginning Java and the fly likes Beginner Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Beginner" Watch "Beginner" New topic
Author

Beginner

venkata ramana
Greenhorn

Joined: Jan 30, 2001
Posts: 3
HI...
can any one tell the difference between
public static void main(String args[]) and
public stativ void main(String[] args)
if there is a difference can anyone explain it in depth pleezzz
:-).
Art Metzer
Ranch Hand

Joined: Oct 31, 2000
Posts: 241
Hi, Venkata.
There is no difference between
public static void main( String[] args ) { }
and
public static void main( String args[] ) { } .
It's all about how you can define an array to Java.
You can say "int[] array" or "int array[]". The
latter syntax is accepted mainly for C/C++
compatibility.
So it doesn't matter at all to Java which syntax
you use. I have read that the former syntax is
preferred, but that preference is one voiced by
humans and convention, not by Java.
Others may have thoughts on the subject....?
Art
Val Dra
Ranch Hand

Joined: Jan 26, 2001
Posts: 439
HI...
can any one tell the difference between
public static void main(String args[]) and
public stativ void main(String[] args)
if there is a difference can anyone explain it in depth pleezzz
:-).
You can declare an array with [] ither way but there is something you must know
let's say you have an array declared like this
int arr[], f;
int []arr, f
in first declaration arr is declared as an array of integers but if is not in 2nd declaration arr is declared as array of integers and so is f . So when you have [] after the type the following declarations followed by , will result in an array reference

Val SCJP <BR>going for SCJD
Susan Hoover
Ranch Hand

Joined: Jan 04, 2001
Posts: 64
Originally posted by Val Dra:
You can declare an array with [] ither way but there is something you must know
let's say you have an array declared like this
int arr[], f;
int []arr, f
in first declaration arr is declared as an array of integers but if is not in 2nd declaration arr is declared as array of integers and so is f . So when you have [] after the type the following declarations followed by , will result in an array reference

Wow. Val, I have to admit that I thought you were wrong, and I was going to prove it. However, my code proved that you were correct! The following code compiles (if you strip out the line numbers). Note lines 6 and 12. In the first case, f is an int. In the second case, f is an int[]. Wow.

--
Susan
Lori Battey
Ranch Hand

Joined: May 17, 2000
Posts: 37
Something new for me too!! Thanks!


Lori Battey<br />SCJP2
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Beginner