Home > Back-end >  Java operator command
Java operator command

Time:09-19

(A) b.t est (); -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- & gt; Compile error



(b) (A). The test (); -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- & gt; Right




Could you tell me why

(A) b doesn't calculate, and add () to calculate first?

CodePudding user response:

(A) b.t est ();
Equal to
(A) (b.t est ());

If b.t est (), the return value is allowed to cast A type, is
A=A (A) b.t est ();
Also nothing wrong with this kind of writing, but you spelled it must be wrong,

CodePudding user response:

First, you b there is no way to test method, A test method of right, and (A) b.t est (); Said to b.t est (); Returns the result of strong to A class;
And (b) (A). The test (); Said, the first will be better to go after A point b in the test method, equivalent to the directly through A call to A method

CodePudding user response:

1, do you have in this test () method must be in class A and b in the corresponding entity class should be no;
2, the highest priority of brackets, so (b) (A) is first converted to A, b and then points out the test () method;
But this so-called right also has a lot of risk, if the type is not compatible with the same type conversion error is unusual,
  • Related