开发者

Math.atan gives an error in java programming

开发者 https://www.devze.com 2023-03-22 06:48 出处:网络
i am usin开发者_开发知识库g haversine formula in java programming (using eclipse). My problem is at the end of the equation where i get an error (atan is underlined) saying that \"The method atan(dou

i am usin开发者_开发知识库g haversine formula in java programming (using eclipse). My problem is at the end of the equation where i get an error (atan is underlined) saying that "The method atan(double) is undefined for the type Math".

i dont know what is the problem. Does anyone have an idea?

    double angle = 45;
    double arctan = Math.atan(angle);


Do you have any other Math class in the same package? Maybe you could try:

double angle = 45;
double arctan = java.lang.Math.atan(angle);


The only possible reason that I can think of for why this might happen is that there is a namespace conflict. That is to say that the compiler thinks the Math in your method is referencing some other Class called Math instead of java.lang.Math

In eclipse if you hover your mouse cursor over Math it will bring up a context window showing you what package it thinks Math belongs to. If it's not java.lang then that's your problem.


Are you programming mobile application and using Java ME? In that case the Math library really doesn't contains atan function. So you have to calculate atan by yourself. This topic was discussed here and also here.

0

精彩评论

暂无评论...
验证码 换一张
取 消