小编Dav*_*idC的帖子

如何解决"静态方法___应该以静态方式访问"警告

我正在阅读Just Java 2这本书,但显然缺少一些基本的东西.这是两个独立的项目.我已经为第二个生成了JAR并将其添加到第一个构建路径中.打印正确的区域但编译器会生成这些警告.这些如何解决?

// -----------------------------------------------------------
// Testing.java
// -----------------------------------------------------------
public class Testing {
    public static void main(String[] args) {
        RectangleDFC r = new RectangleDFC(3, 4);
        System.out.println(r.Area());
            // WARNING: The static method Area() from the type RectangleDFC
            //          should be accessed in a static way
        r.SetSides (10, 10);
            // WARNING: The static method SetSides(int, int) from the type
            //          RectangleDFC should be accessed in a static way
        System.out.println(r.Area());
            // WARNING: The static method Area() from the type RectangleDFC
            // …
Run Code Online (Sandbox Code Playgroud)

java static warnings class

1
推荐指数
1
解决办法
2万
查看次数

标签 统计

class ×1

java ×1

static ×1

warnings ×1