Topic: 各位大哥看看有什么错,小弟我看不出。(Solved, pls ignore.)

  Print this page

1.各位大哥看看有什么错,小弟我看不出。(Solved, pls ignore.) Copy to clipboard
Posted by: wwd1015
Posted on: 2005-07-23 19:39

请使用准确的文字描述作为标题
Your next post without a proper Subject will be removed.

Do you have problem in reading the error messages issued by javac?
Math.round(double) returns a long, so it should be:
long x = Math.round (Math.PI * 20.0);

In addition, you would like to add the public keyword:
public class No

Original subject :
各位大哥看看有什么错,小弟我看不出。


 
class No {
public static void main (String [] args) {
int x = Math.round (Math.PI * 20.0);
System.out.println Fight;
}
}

2.Re:各位大哥看看有什么错,小弟我看不出。(Solved, pls ignore.) [Re: wwd1015] Copy to clipboard
Posted by: wwd1015
Posted on: 2005-07-24 08:18

谢谢了
标题我会注意的。
代码看书的,没想到书都错了。
顺便再请教一下long是什么类型的变量,
还有加不加public好像没什么不同啊。

3.Re:各位大哥看看有什么错,小弟我看不出。(Solved, pls ignore.) [Re: wwd1015] Copy to clipboard
Posted by: 阳光地带
Posted on: 2005-07-26 09:47

long 是长整型吧.
加了public后,类名和文件名要同名的.不加public,文件名可以随便取了.

4.Re:各位大哥看看有什么错,小弟我看不出。(Solved, pls ignore.) [Re: wwd1015] Copy to clipboard
Posted by: FlowerBud
Posted on: 2005-07-26 15:31

Math.PI是double型的,你的x也应该定义为double型,或者把Math.PI*20.0强制转换成int型

5.Re:各位大哥看看有什么错,小弟我看不出。(Solved, pls ignore.) [Re: FlowerBud] Copy to clipboard
Posted by: why
Posted on: 2005-07-26 19:41

FlowerBud wrote:
Math.PI是double型的,你的x也应该定义为double型,或者把Math.PI*20.0强制转换成int型

Read carefully!
It's Math.round !!

6.Re:各位大哥看看有什么错,小弟我看不出。(Solved, pls ignore.) [Re: wwd1015] Copy to clipboard
Posted by: wwd1015
Posted on: 2005-07-27 08:10

class No {
public static void main (String [] args) {
int x = (int) Math.round (Math.PI*20.0);
System.out.println Fight;
}
}

这样可以吗?好像和Math.round不同吧.long类型的有什么特点,还是不知道。
还有各位能推荐几本好书吗,包含基础知识的,谢谢了。

7.Re:各位大哥看看有什么错,小弟我看不出。(Solved, pls ignore.) [Re: wwd1015] Copy to clipboard
Posted by: IT_liuxue2005
Posted on: 2005-07-29 17:14

这个哥们真逗!你是不是刚来学啊!这多简单啊!太基础了!

8.Re:各位大哥看看有什么错,小弟我看不出。(Solved, pls ignore.) [Re: wwd1015] Copy to clipboard
Posted by: wangdingyuan
Posted on: 2005-08-01 14:56

BlushBlushBlushBlush
<Thinking in java>


   Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent
Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1
客服电话 18559299278    客服信箱 714923@qq.com    客服QQ 714923