class Point{
double x,y;
Point(double x,double y){
this.x = x;
this.y = y;
}
double getX(){
return x;
}
double getY(){
return y;
}
}class Circle{
Point o;
double r;
Circle(Point o, double r){
this.o = o;
this.r = r;
}
void test(double m,double n){
26 if(|o.x - m| * |o.x - m| + |o.y - n| * |o.y - n| > r * r)
27 System.out.Println("the Point not in the circle");
else
System.out.println("the Point in the circle");
}
}
public class TestPoint{
public static void main(String[] args){
Point p1 = new Point(3,5);
Point p2 = new Point(6,7);
37 Circle mi = new Circle((3,5),5);
39 test.(6,7);
}
}请高手帮我找出错误。
26 :非法表达式
27:需要')'
System.out.Println("the point not in the circle");
^
37:需要')'Circle mi = new Circle((3,5),5);
^
39:需要标识符
test.(6,7);
^
double x,y;
Point(double x,double y){
this.x = x;
this.y = y;
}
double getX(){
return x;
}
double getY(){
return y;
}
}class Circle{
Point o;
double r;
Circle(Point o, double r){
this.o = o;
this.r = r;
}
void test(double m,double n){
26 if(|o.x - m| * |o.x - m| + |o.y - n| * |o.y - n| > r * r)
27 System.out.Println("the Point not in the circle");
else
System.out.println("the Point in the circle");
}
}
public class TestPoint{
public static void main(String[] args){
Point p1 = new Point(3,5);
Point p2 = new Point(6,7);
37 Circle mi = new Circle((3,5),5);
39 test.(6,7);
}
}请高手帮我找出错误。
26 :非法表达式
27:需要')'
System.out.Println("the point not in the circle");
^
37:需要')'Circle mi = new Circle((3,5),5);
^
39:需要标识符
test.(6,7);
^
解决方案 »
- 关于播放MP3的程序
- java圆形按钮怎么添加圆形图标
- 服务端和客户端的文件传送
- outOfMemoryError一般怎样改正?
- s.getClass().getName().compareTo("java.lang.String") == 0和s instanceof String判断类型时在性能或内部实现是有什么区别
- 这里就真的没有对java比较熟悉的人吗?还是世态炎凉呀!
- IO读写流的一个乱码问题
- 帮我写程序!急用,
- 求解?在JB6中发布时总是报CORBA page||IDL page是怎么回事!急急!!
- 请问各位大虾,怎样把一个string类型变量转变成int型?
- JPopupMenu实现右击显示三级联动菜单怎么样实现?
- 求正则表达式
楼主【zyp627】截止到2008-07-22 20:48:14的历史汇总数据(不包括此帖):
发帖的总数量:57 发帖的总分数:790 每贴平均分数:13
回帖的总数量:28 得分贴总数量:0 回帖的得分率:0%
结贴的总数量:57 结贴的总分数:790
无满意结贴数:1 无满意结贴分:20
未结的帖子数:0 未结的总分数:0
结贴的百分比:100.00% 结分的百分比:100.00%
无满意结贴率:1.75 % 无满意结分率:2.53 %
敬礼!
class Point {
double x, y; Point(double x, double y) {
this.x = x;
this.y = y;
} double getX() {
return x;
} double getY() {
return y;
}
}class Circle {
Point o;
double r; Circle(Point o, double r) {
this.o = o;
this.r = r;
} void test(double m, double n) {
if ((o.x - m) * (o.x - m) + (o.y - n) * (o.y - n) > r * r)
System.out.println("the Point not in the circle");
else
System.out.println("the Point in the circle");
}
}public class TestPoint {
public static void main(String[] args) {
Point p1 = new Point(3, 5);
Point p2 = new Point(6, 7);
Circle mi = new Circle(p1, 5);
mi.test(6, 7); }
}
这是应该是你要的吧,错误有点奇怪。
返回 double 值的绝对值。
static float abs(float a)
返回 float 值的绝对值。
static int abs(int a)
返回 int 值的绝对值。
static long abs(long a)
返回 long 值的绝对值。 另外求平方可以用:
static double pow(double a, double b)
返回第一个参数的第二个参数次幂的值。 所以 if( ¦o.x - m ¦ * ¦o.x - m ¦ + ¦o.y - n ¦ * ¦o.y - n ¦ > r * r)
可以改为:
if ( (Math.pow(Math.abs(o.x - m), 2) + Math.pow(Math.abs(o.y - n), 2)) > Math.pow(r, 2) )
还有要说明一点,java是对对象进行操作的,像(5,7)是不能被java识别的。在java中没有操作符重载的哦
class Point{
double x,y;Point(double x,double y){
this.x = x;
this.y = y;
System.out.print("sjhdfkhwekslkd");
}double getX(){
return x;
}
double getY(){
return y;
}
}class Circle{
Point o;
double r; Circle(Point o, double r){
this.o = o;
this.r = r;
System.out.print("sjhdfkh==-slkd");
}
void test(double m,double n){
if( (o.x - m) * (o.x - m) + (o.y - n) * (o.y - n) > r * r)
System.out.println("the Point not in the circle");
else
System.out.println("the Point in the circle");
}
}public class TestPoint { /**
* @param args
*/
public static void main(String[] args) {
System.out.print("sjhdfkhwekslkd");
Point p1 = new Point(3,5);
Point p2 = new Point(6,7);
System.out.print("sjhdfkhweksl+\n");
Circle mi = new Circle(p1,5);
System.out.print(String.valueOf(mi.r));
System.out.print(String.valueOf(mi.r)+"\n");
mi.test(6,7);
// TODO 自动生成方法存根 }}
和上面的那个亲兄弟一样,没问题
输出结果为:
sjhdfkhwekslkdsjhdfkhwekslkdsjhdfkhwekslkdsjhdfkhweksl+
sjhdfkh==-slkd5.05.0
the Point in the circle
double x,y;
Point(double x,double y){
this.x = x;
this.y = y;
}
double getX(){
return x;
}
double getY(){
return y;
}
}class Circle{
Point o;
double r;
Circle(Point o, double r){
this.o = o;
this.r = r;
}
void test(double m,double n){
if((o.x - m ) * (o.x - m ) + (o.y - n) * (o.y - n ) > (r * r))
System.out.println("the Point not in the circle");
else
System.out.println("the Point in the circle");
}
}public class TestPoint {
public static void main(String[] args){
Point p1 = new Point(3,5);
Point p2 = new Point(6,7);
Circle mi = new Circle(p1,5);
mi.test(6.0,7.0);
}
}你想写的的是这个吧??
2 创建 Circle对象 Circle c = new Circle(new Point(3,5),5);
3 对于Circle 中的方法test,当c.test();调用 不能直接调用的