Mana Yang Bener, String[] args atau String args[]
Pada dasarnya terserah aja mau taruh di belakang atau di depan
tuh tanda kurung siku..
Tapi masalahnya, (ini sih kata Alex Buckley [Pemimpin dari Java Languange
Spesification] dan juga JVMS [Java Virtual Machine Specification])
Begini nih kata beliau :::
String[] is preferred because it keeps the type of args — array of String — all together. In a more complicated and poorly formatted method signature, it could be easy to miss a [] after a parameter name.
Which is pretty much what I thought. Alex goes on to point out that the following statements are equivalent:
String[][] s;
String[] s[];
String s[][];
However, the middle form is a maintenance headache and is not recommended. In general, arrays cause all sorts of problems at runtime — bounds must be checked as well as the runtime type of the array:
Object[] o = new String[5];
o[0] = new Integer(1); //Compiles OK, but gives ArrayStoreException
For these reasons and because they offer more flexible options, the Collections classes are preferred to arrays.
Jelas kan??
Jadi String[] args mempertahankan bentuknya bahwa ia adalah array of String
Happy Java Programming ---> Wilbert
Posted at 06:27PM Feb 22, 2008 by Wilbert in Java | Comments[0]