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