简体   繁体   English

这两个Java代码段之间有什么区别?

[英]Whats the difference between these two java code snippets?

I have this code i am doing for university. 我有我正在上大学的这段代码。 The first code works as expected, the second one provides different results. 第一个代码按预期工作,第二个代码提供不同的结果。

I can not see what they are doing differently?? 我看不到他们在做什么不同?

first: 第一:

public Mat3 getNormalMatrix() {
    return new Mat3(this.getInverseMatrix()).transpose();
}

second: 第二:

public Mat3 getNormalMatrix() {
    Mat4 mat = this.getInverseMatrix();
    Mat3 bla = new Mat3(mat);
    bla.transpose();
    return bla;
}

The first one returns the result of transpose() the second one returns bla. 第一个返回transpose()的结果,第二个返回bla。

In the second example, you want 在第二个示例中,您想要

bla = bla.transpose();

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM