Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

what is a[ i ] = a[ j ].times(a[k]);

Status
Not open for further replies.
Hi prosper:

Let me say that you are a very observant person. Well, you are right, those lines in the tutorial has an error and can confuse the user. First, the line:
Code:
a[i] = a[j].times(a[k]);

would compile depending on the "a" array declaration, where the type of the elements of the array should have a times() method defined (Object doesn't have such method). Anyway, the next example with vectors:

v.setElementAt(v.elementAt(j).times(v.elementAt(k)), i);

would NEVER compile!, because the elementAt() method returns an Object which have no times() method defined. So if you don't explicitly cast the returned value it wont compile. It should be:

v.setElementAt(((ClassWithTimesMethodDefined)v.elementAt(j)).times(v.elementAt(k)), i);

If you find that "ClassWithTimesMethodDefined" class please let me know. I have heard about that method but I cant remember where. Certainly it is not an Object method.

Hope it helps.

Pedro Andrés Solorzano
Pontificia Universidad Javeriana
Bogotá, Colombia, SurAmérica.

Let me know if this post have actually helped you, by clicking the purple star.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top