This week's book giveaway is in the Agile forum.
We're giving away four copies of Head First Agile and have Andrew Stellman & Jennifer Greene on-line!
See this thread for details.
Win a copy of Head First Agile this week in the Agile forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Error in using "assert" in java program....  RSS feed

 
Pras Tiwari
Ranch Hand
Posts: 186
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
This is my simple java class:-

public class Counter{
public static void main(String[] args) {
int i=3;
assert i % 3 == 2 : i;
}
}

When I am trying to run above class,It gives me error like :-
------------------------------------------------
Exception in thread "main" java.lang.Error: Unresolved compilation problem:
Syntax error on token "%", ";" expected

at Counter.main(Counter.java:5)
------------------------------------------------


What is the problem in above code?
Please help me,
Thank you,
Pras
 
Ajay Singh
Ranch Hand
Posts: 182
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
works fine here... which version/make of compile and sdk you are using
 
Pras Tiwari
Ranch Hand
Posts: 186
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am using jdk1.4.2 version. Is "assert" is compatible with jdk1.5 onwards???
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!