• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Paul Clapham
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Roland Mueller
  • Piet Souris
Bartenders:

Beginner

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
:-).
 
Ranch Hand
Posts: 241
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 439
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Something new for me too!! Thanks!
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic