2016-05-06 12 views
2

Ich programmiere eine rekursive Definition der Sinus-Funktion in Java mit seiner Taylor-Approximation, aber eine noSuchMethodException beim Ausführen des Codes. Hier ist, was ich bisher habe:Getting a noSuchMethodException

public static void Main(String[] args){ 
    System.out.println("The approximate sine of pi over 2 with an accuracy index of ten is:"); 
    System.out.println(Mathematics.recursiveSine(Math.PI/2,10)); 
} 

public static double recursiveSine(double value, int index){ 
    if(index==1) { 
     return value; 
    } 
    return ((double) ((-1)^(2*index + 1)) * Math.pow(value,2*index + 1)/factorial(2*index + 1)) + recursiveSine(value, index-1); 
} 

public static int factorial(int value){ 
    return value==1 ? value : value*factorial(value-1); 
} 
+0

Sie haben einen Tippfehler sein, die wichtigste Methode genannt 'main', nicht' Main'. – Berger

+0

'main' muss einen Kleinbuchstaben' m' haben. – ajb

+0

'Mathematik.ist nicht notwendig, wenn es in der gleichen Klasse aufgerufen wird – Andrew

Antwort

5

Ihre Hauptmethode muss Kleinbuchstaben sein.

Sie haben

public static void Main(String[] args){ 

public static void main(String[] args){ 
Verwandte Themen