Edit: I do not think how the second question gives me an answer. I already have a clear artist (e []), who is not the author of the second question. I also tried something like seq1 = (integer []) iw.result (); But that does not work either.
I have the following code:
Public class is something comparative & lt; E & gt; & Gt; {E] [] Sack; Some public () {seq = (e []) new object [100]; } Public E [] results () {Return sequence; } Public static zero main (string [] args) {some & lt; Integer & gt; Iw = new something & lt; Integer & gt; (); Integer [] sAC1 = new integer [100]; Seq1 = iw.result (); }}
I get a misunderstanding in this way: [Object can not be inserted in [Comparative
, so I change some-maker to:
seq = (e []) new comparative [100];
Now I get a misunderstanding in this way: [Comparative can not be inserted into [integer]
Is there any way to work above code? I know I'm better off working with collections, but I'm just curious what's wrong with my code.
Here are some problems.
First of all, this is not an unlimited general parameter; enclosed comparative
During the extinction of type, your class has been declared as:
public class something & lt; E comparative & lt; E & gt; & Gt; {E] [] Sack; }
... is bound to e
comparative
.
public squares some {comparative [] Seq; }
This therefore your casting is not working, because object
is not a comparable
. You want to use the new comparative
instead.
public class something & lt; E extractable comparative & lt; E & gt; & Gt; {E] [] Sack; Some public () {seq = (e []) new comparative [100]; }}
Now, Java and should break on the previous two statements.
integer [] seq1 = new integer [100]; Seq1 = iw.result ();
is bound to iw.result ()
comparative []
, not integer []
. A comparative []
can never become a integer []
.
You can do this instead to leave ClassCastException
:
comparative [] seq1 = new integer [100];
This will work since a integer
is comparative
. This is due to the fact that arrays are co-sensation (which is a subtype of a integer [a]
a comparable []
).
No comments:
Post a Comment