Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

when args.length is checked whats the output?

 
kavitha yogaraj
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This program was there in www.javachmp.com java test



when I executed this program I had no output
but the output in the exam result is onetwo--
the explaintation is

Be careful of the braces, the System.out.print("--") is not included in the for loop block, so it will be executed once after the loop is finished


java Tester one two

The first argument represents the name of the class, and what come after are the program arguments.

 
Jim Hoglund
Ranch Hand
Posts: 525
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Isn't CommandLineTest the name of your class?

Jim ... ...
 
kavitha yogaraj
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jim Hoglund wrote:Isn't CommandLineTest the name of your class?

Jim ... ...


yes, it is the name of my class.
 
Jim Hoglund
Ranch Hand
Posts: 525
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So what happens when you run "java CommandLineTest one two" ?

Jim ... ...
 
kavitha yogaraj
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jim Hoglund wrote:So what happens when you run "java CommandLineTest one two" ?

java CommandLineTest one two" -> this is not what i run.
c:\java\javac Commandline is what I run One two i the output
 
Justin Rundle
Ranch Hand
Posts: 123
Hibernate Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What Jim is trying to say is that instead of running:



Should you not be running this instead:



Typo... or copy/paste error?
 
Abimaran Kugathasan
Ranch Hand
Posts: 2066
Clojure IntelliJ IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Kavitha, => CarefullyChooseOneForum <= and => UseCodeTags <=. What is your question?
 
Justin Rundle
Ranch Hand
Posts: 123
Hibernate Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am in the right forum and I was responding to the post and I did choose the right tags... why dont you read the whole thread first before posting you reply...
 
Abimaran Kugathasan
Ranch Hand
Posts: 2066
Clojure IntelliJ IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Justin Rundle wrote:I am in the right forum and I was responding to the post and I did choose the right tags... why dont you read the whole thread first before posting you reply...


Addressed to Kavitha....
 
Justin Rundle
Ranch Hand
Posts: 123
Hibernate Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Abimaran Kugathasan wrote:
Justin Rundle wrote:I am in the right forum and I was responding to the post and I did choose the right tags... why dont you read the whole thread first before posting you reply...


Addressed to Kavitha....


Apologies.
 
Abimaran Kugathasan
Ranch Hand
Posts: 2066
Clojure IntelliJ IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Justin Rundle wrote:

Apologies.

Again => NoNeedToSaySorry <=. Thanks for caring!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic