小编Ada*_*dam的帖子

Java的负数乘法

在正常的数学术语中,-1756046391*-1291488517将等于2267913749295792147.

当我在java中输入完全相同的等式时,我得到答案:-1756046391*-1291488517 = 19.

任何人都可以对此有所了解吗?

java multiplication

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

创建一个被调用的类的新实例而不是父类

当方法在父类中时,如何返回被调用的类的实例.

例如.在下面的示例中,B如果我调用,如何返回实例B::foo();

abstract class A
{
    public static function foo()
    {
        $instance = new A(); // I want this to return a new instance of child class.
             ... Do things with instance ...
        return $instance;
    }
}

class B extends A
{
}

class C extends A
{
}

B::foo(); // Return an instance of B, not of the parent class.
C::foo(); // Return an instance of C, not of the parent class.
Run Code Online (Sandbox Code Playgroud)

我知道我可以这样做,但有一个更简洁的方式:

abstract class …
Run Code Online (Sandbox Code Playgroud)

php inheritance static

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

标签 统计

inheritance ×1

java ×1

multiplication ×1

php ×1

static ×1