args « string « Java Data Type Q&A

1. difference fn(String... args) vs fn(String[] args)

Whats this syntax useful for :

    **function(String... args)**
Is this same as writing
    **function(String[] args)**
with difference only while invoking this method or is there ...

2. What is "String args[]"? in Java

I'm very beginner for programming. In Java.

public static void main(String []args)
What's String args? and What kind of case do you use args at? I am fortunate when I have you teach it ...

3. Why is String[] args required in Java?

I understand that String[] args is an array of strings passed into main as parameters.

java Print "Hello, World!"
class Print {
  public static void main(String[] args) {

4. Java Beginner question about String[] args in the main method

So I just tried excluding String[] args from the main method It compiled alright ! But JVM is showing an exception Why did it compile when String[] args HAS to be included every time ...

5. what is the use of string args[] in main method

Possible Duplicate:
What is “String args[]”? in Java
What is the purpose of this method in java. If we not use what happens? If i give some ...

6. string args error on compiling command prompt

I'm a biginner and got an error on this command, whou'ld someone please help me ? I've got this when I tried to compile my first programm.... get this in command prompt...


7. how to use (String [] [] args) in java

how to use (String [] [] args) in java and write program of 2d array.

8. What does "String[] args" contain in java?

When I run the following program:

public class Test
    public static void main(String[] args)

9. Is there a difference between main(String args[]) and main(String[] args)?

Is there a difference between:

public void main(String args[]) { ... } 
public void main(String[] args) { ... }
I don't believe so, but I am wondering.

10. What is Difference between using the Scanner class in Java for input and using Strings Args[] with parseint?

What is the difference between the following

import java.util.Scanner;
//Creating the scanner
Scanner input=new Scanner(;
System.out.println("Enter the number 1");
int number1=input.nextInt();
int number1=parseInt(args[0]);

11. how to reset program to main string args?

I am writing a program and if it catches an Exception I want to reset the whole program is there anyway please tell me I really need to finish it tonight ...

12. Why we don't get error when we don't pass any command line argument?

we give parameter args[] in main(). When we call any parameterized method without passing enough arguments, it gives error. Then why it is not the case with main method?

13. What does (String args []) mean?

I have this in the

 public static void main(String args[]) throws Exception_Exception {
    URL wsdlURL = CallSService.WSDL_LOCATION;
    if (args.length > 0) { 

14. differance between string[ ] and args[ ]

There is no difference as such. When you say String[], it is called string array and args[] is a variable name for an array! In Java you can use either of ...

16. String args[ ] in main

Hi! I am new to java and when I analyzed the command line public static void main(String args[ ]){ I found that any modifier works fine(came to know through java ranch discussions that it is already registered as a bug).I found convincing answers for static and void too. But what bewilders me is why one has to pass String args[ ] ...

17. why always "string args[ ]"

When SUN created Java, they sat down and said "OK, what is the ONE best signature that we can use as a starting point for ALL applications". They decided that String can encompass all other data types as input. So they coded the compiler to always look for that particular method signature, and when found, use it to kick off the ...

18. (String[] args) vs. (String args[])

In main() there shouldn't be any difference. It only matters if you are making multiple declarations of arrays. For example: String [] arr1, arr2; I just declared two String array references. However, if I use String arr1 [], arr2; I declare one String array reference arr1, and one String reference arr2. To be able to declare 2 String array references, I ...

20. String [ ] args

A String array is the argument type to the main method used as a Java entry point: public static void main(String[] args){ ... } Any legal identifier can be used for this array, although "args" or "argv" are probably the most common (for "arguments" and "argument values" respectively). The general purpose of this array is a means to pass initial information ...

21. main(String args[]) versus main(String[] args)

I just started a Java class and my instructor mentioned the second approach is preferred, BUT... I have to agree that using the first approach for defining an array (int[] = int) that one can very quickly see the variable is an array w/o having to read the entire line of code. Thank you very much.

22. what does (String[ ] args) mean?

Hi, Mike Well, any Java program needs a starting point. When a class has a method with the signature public static void main(String args[]) that means that class is elegible as an application starting point. For instance: public class Jedi{ public static void main(String args[]){ System.out.println("Hello Luke!"); } } After compiling your class with the javac.exe (in Windows) or the javac ...

23. main ( String[] args) question

Awesome info guys. I appreciate the time you guys take to answer silly questions like mine. I was hoping that if I am going to take the argument and then change it into an int array or a char array it would seem easier, in my mind, to do it right off the bat. I didn't know if we could over ...

24. String args[] vs. String[] args

As people have already said, it makes no difference to the behaviour, except in the case of declaring multiple variables in one line. And, frankly, if you declare some Strings and some arrays of Strings, all in one line, you deserve to be forced to write Visual Basic for the rest of your career. I think the "String args[]" version is ...

25. Move implemenation out of main(String[ ] args)

Im looking for some guidance as to how i would go about moving implemenation out of main(String[ ] args). I have tried to do this a few times and all i seem to do is mess up my code. public class Dvdinventory { public static void main(String args []) { DVD dvd; dvd = new DVD(1, "The Unit", 1, 24.95); System.out.println(dvd); ...

26. String args[]

27. Why main(String [] args) method must be public

I can declare a class as non-public and packageless, and then run its main() method from the current directory. Why doesn't the main method run if i dont declare it as public? My question actually is but for the main method, the non-public class's method would actually not be accessible from other packages. So, from the current directory, since the non-public ...

28. String[] arg Vs String... args

They are not 100% the same. String[] requires just that - an array of Strings. String... on the other hand, accepts both an array of Strings but also any number of Strings. As you can see, String... allows anything that String[] allows but not vice versa. Now, given that A) won't even compile, what do you think the answer is?

29. Why do we give "String [] args" as an argument to main??

When you type "java MyClass", the JVM goes and looks for a method in MyClass with the signiature "public static void main (String [] args)" (although the specific name of the String array can be anything you want). If that method is not there, the JVM can't start up your program. However, it is perfectly valid to have a class that ...

30. main(String[]args)

it will not be used, but you still have to have it there. The jvm is EXPLICITLY looking for a method with that signiature. So if you wrote public static void main(){...} and didn't have the "String [] args", the jvm would not be able to find the 'entry point' into your program, and would complain. Note that the variable name ...

31. Issue while handling String[] args in Main method

Hi Gurus, I know its a basic question. but i dont how it is handled in java. I have a program that handles 5 String[] args. The input args are going to be ipaddress time username encryptedpassword role. 1306149242287 Admin Tf]Mbp9}`n,$H'Ld0\"Vh|% AdminUser note that the encrypted password contains " (Double Quotes). Becuase of this the Java main method takes `Tf]Mbp9}`n,$H'Ld0\"Vh|% ...

32. main(String... args) problems

public void startBiddingIn(final FakeAuctionServer auction) { // Start testing in another thread Thread thread = new Thread("Test Application") { @Override public void run() { try { // ERROR: The method main(String[]) in the type Main is not applicable for the arguments (String, String, String, String) Main.main(FakeAuctionServer.XMPP_HOSTNAME, SNIPER_ID, SNIPER_PASSWORD, auction.getItemId()); } catch (Exception e) { // Temp solution of just printing out ...

33. String[] args

I think the poster here wants to know the rationale behind the requirement of main() with String array argument. The question she should ask is, Why did they(creators of java) made it compulsory for main to have an argument..... Since it is not a requirement in c#..... What advantage does it(making it compulsory) give us. Even if she did not ask ...

34. Main(String [] args)

35. What does String args[] stand for?

36. Passing values to main(String args[]) ?

Ok so let me see if I understand. If I were to write c:\java>java Hello then args[0] would contain nothing? but if I were to write c:\java>java Hello msg then args[0] would be msg. I have just used run configuration in eclipse and used (x)=Arguments option and wrote something in there and ran the program and args.length printed 1. Is this ...

37. use of String[] args

38. ReadLine(String fmt,Object... args) of c=onsole class

ya I checked with API documentation of Java 6. it says: public String readLine(String fmt, Object... args) Provides a formatted prompt, then reads a single line of text from the console. Parameters: fmt - A format string as described in Format string syntax. args - Arguments referenced by the format specifiers in the format string. If there are more arguments than ...

39. use of (String args[])

40. String[]args

41. what is the use of passing String[] args in main() method?

What's the use of that middle pedal in my car? I never bothered to find out about these basic things, I just got in, started driving without having a clue what to do, and hoped for the best. I didn't bother reading the manual, or asking my driving instructor, I figured I'd just ask a bunch of random strangers instead

42. String[] args fights String... args

44. what happens when main(String[] args)

Hi techies, I am trying to understand, "how the JVM invokes public static void main(String[] args)". I had gone through JVM tutorial, and found that there are 2 different types of classloaders 1. bootstrap loader 2. user defined class loader. I had gone through java api for class loader class. i did not find the method main(String[] args). I am having ...

45. Need of String args[] in main()

Hai all, i had a small doubt regarding the usage of String args[] in main function. When we are not passing any parameters to the program also, we have to give this String args[]. why should we do so. I mean when we pass some arguements to the program then there is the usage of String args[] but when we are ...

47. String[] arg Vs String... args

Ofcourse answer is "C". C don get confused with these two Syntax Declarations. Though String... and String[] defines an Array, with ... we are defining there could be n no. of object of that type. String[] need some String Array object to be assigned.... Talking about main function, in command line arguments, we can send ...n.... no. of commands. So, in ...

48. why we use string args[] in void main()

Because that's roughly how C did it and Java is based on C. You can get all the input arguments using JMX, but it's rather complicated and not useful except in obscure cases. (I use it to determine if a unit test is running in debug and change the timeouts in my tests so I can step through a test without ...

49. Difference between (String....args) & (String [] args)

"String... args" will declare a method that expects a variable number of String arguments. The number of arguments can be anything at all: including zero. "String[] args" and the equivalent "String args[]" will declare a method that expects exactly one argument: an array of strings. One difference that might not spring out from those observations is that in the second case ...

50. Restart main(String args[])

Depends a bit. I think I'd go for a loop in main() so that "reset" terminates the current iteration through the loop, effectively restarting from the top of the loop. If terminating the current iteration is complicated, a possible hack is to throw an exception (declare your own exception subclass just for this purpose), catch in the loop in main and ...

51. Why String args[] is mandatory in main() ?

The method signature is a combination of the name of the method and the parameters it takes. As such, two methods with the same name but different parameters are different -- indeed, this is what is called overloading a method. The JVM knows the signature of the main method to look for and run automatically. Allowing for a no-parameter version of ...