The moose likes Beginning Java and the fly likes Assertion error Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Assertion error" Watch "Assertion error" New topic

Assertion error

priyapapathi sivanandampapathi

Joined: Apr 19, 2005
Posts: 3
//please see the following program..It compiles properly but it gives an assertion error..
class cal
public int n;
public int fact(int n)
if (n==0)
return 1;
return fact(n-1)*n;
public class Factorial
public static void main(String[] args)
cal c=new cal();
DataInputStream d=new DataInputStream(;
System.out.print("Enter the Value:");
catch(IOException ie){System.out.println(ie);}
System.out.println("Factorial: "+ c.fact(c.n));
Raj Young

Joined: Mar 16, 2005
Posts: 9
It works fine. I don't see any error. can u post the error and the JDK used?
tue march

Joined: Mar 09, 2005
Posts: 16
Hi priya,

the program what u have given is working fine except it says deprecated problems. since you are using readLine method which is a deprecated one
i dont find any other problems.

one important thing priya, i the program i dont see where you are checking the number entered, i know you are using assert to check if somebody enters negative number. but where is the assertion statement in program. plz do check once again and revert back to me. ok .

Have a nice day,
Good Guy
I agree. Here's the link:
subject: Assertion error
It's not a secret anymore!