File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Assertion error" Watch "Assertion error" New topic
Author

Assertion error

priyapapathi sivanandampapathi
Greenhorn

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

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
Greenhorn

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: http://aspose.com/file-tools
 
subject: Assertion error