Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Beginner

 
venkata ramana
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 241
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 439
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Susan Hoover
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Something new for me too!! Thanks!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic