Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Assertion problem

 
Komal Arora
Ranch Hand
Posts: 91
Eclipse IDE Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
the question is from the k&S book and is as follows:



which sets of commands will compile and run without exception or error:

1) javac Antique.java
java Antique

2) javac Antique.java
java -ea Antique

3) javac -source 6 Antique.java
java Antique

4) javac -source 1.4 Antique.java
java Antique

5) javac -source 1.6 Antique.java
java -ea Antique

the answer to the above is : 1 and 3.

i understood why 1 and 3 are correct.
i understood why 4 is incorrect, which is because the code uses generics which werent introduced till java 5, hence the command statement is wrong

i did not understand why 2 and 5 are wrong! Can anyone please explain the fact!
 
Matthew Brown
Bartender
Posts: 4567
8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hint: Is the assertion correct? What is the length of the args array?
 
Komal Arora
Ranch Hand
Posts: 91
Eclipse IDE Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
OH! SILLY ME!

thanks Matthew!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic