• Post Reply Bookmark Topic Watch Topic
  • New Topic

Command Line args  RSS feed

 
Balaji Bang
Ranch Hand
Posts: 182
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

What is the difference between :

java Capture "Sun Certified" //Capture is classname

java Capture Java Programmer
 
Ankit Garg
Sheriff
Posts: 9610
37
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In the first case the arguments of the main method will contain this array

args = new String[]{"Sun Certified"};

and in the second case the arguments will contain

args = new String[]{"Java","Programmer"};

[Edit: removed an error from the code :lol: ]
 
Yuan Du
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
new String[1]{"Sun Certified"};

will this compile?
 
Prav sharma
Ranch Hand
Posts: 102
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Java ProgName <argument list (0 index based)>

So

java Capture Java Programmer

args[0]- Java
args[1] - Programmer

For java Capture "Sun Certified"

args[0]="Sun Certified" // Double quotes here


Banu Chowdary wrote:Hi

What is the difference between :

java Capture "Sun Certified" //Capture is classname

java Capture Java Programmer
;
 
Ankit Garg
Sheriff
Posts: 9610
37
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yuan Du wrote:
new String[1]{"Sun Certified"};

will this compile?


What is happening to me I am making too many mistakes :x
 
Sachin Adat
Ranch Hand
Posts: 213
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ankit Garg wrote:What is happening to me I am making too many mistakes :x

Its OK dude, you are clearing the actual doubt....... and that's what really matters.
About others finding your mistakes, just means all are alive out here..........

You could have said "I put the length just to make it clear to understand"...........
 
Ankit Garg
Sheriff
Posts: 9610
37
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sachin Adat wrote:You could have said "I put the length just to make it clear to understand"...........


Well to be honest, I indeed added the length to make it easier to understand but didn't realize that it would be an invalid syntax then :XD:
 
Sachin Adat
Ranch Hand
Posts: 213
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ankit Garg wrote:Well to be honest, I indeed added the length to make it easier to understand but didn't realize that it would be an invalid syntax then :XD:

I also thought that you had put that in purpose, so I didn't point it out...........
 
Abhi vijay
Ranch Hand
Posts: 509
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


Here [Ljava.lang.String;@3e25a5 is printed..java. But String overrides the toString() :?: method.
 
Punit Singh
Ranch Hand
Posts: 952
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here args is not String object, it is an Array Object that contains Strings series.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!