The factorial method which you have written is fine, but I don't understand why you want to store the numbers in myVal array. You remove it and just call the method and it will give you the desired result.
Static variables are class variables which has only one copy for all the instances. All the instances share the same reference of those variables. So if a instance change its value to some xyz then the other instance when refer the variable it will give the xyz value. To call Static method on e doesn't need to instantiate the class, just by saying Class.method it can access the method. Normally the methods which doesn't change the state of the object can be made static. Hope this helps. -----Original Message----- From: [Vaishali S. Pandya] [mailto:[EMAIL PROTECTED]] Sent: Monday, May 13, 2002 11:24 AM To: [EMAIL PROTECTED] Subject: why this is not working No completime error is there but the output is unexpected <HTML> <HEAD> <%! int myval[]= new int[100]; int v=0; %> <TITLE> Factorial </TITLE> </HEAD> <BODY> <% int a=0; out.println(v); %><br><% for (a=0;a<v;a++){ out.println(myval[a]); } out.println(fact(5)); %> <%! public int fact(int i){ myval[v++] = i; if (i==1){ return i; } return i*fact(i-1); } %> </BODY> </HTML> =========================================================================== To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST". For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST". Some relevant FAQs on JSP/Servlets can be found at: http://archives.java.sun.com/jsp-interest.html http://java.sun.com/products/jsp/faq.html http://www.esperanto.org.nz/jsp/jspfaq.jsp http://www.jguru.com/faq/index.jsp http://www.jspinsider.com ==========================================================================To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST". For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST". Some relevant FAQs on JSP/Servlets can be found at: http://archives.java.sun.com/jsp-interest.html http://java.sun.com/products/jsp/faq.html http://www.esperanto.org.nz/jsp/jspfaq.jsp http://www.jguru.com/faq/index.jsp http://www.jspinsider.com