2014-08-31 52 views
0
import java.awt.Rectangle; 

public class IONS { 
    public static void main(String[] args) { 
     Rectangle x = new Rectangle(10, 20); 
     int width = x.width(); 
     System.out.println(width); 
    } 
} 

编译时第7行有错误,我在哪里出错?方法宽度()未定义为类型矩形

ERROR: The method width() is undefined for the type Rectangle IONS.java 

回答

1

要么使用.getWidth()(并期望double!),或者只是使用.width(直接从您的矩形检索的宽度)。

没有方法.width()

相关问题