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!

using maths functions / object pointers

Status
Not open for further replies.

Toe

Programmer
Oct 26, 2001
71
GB
hi,

i'm very new to java so am going to ask a couple of really silly questions:

1) I have a simple program I wrote that uses soem maths functions : eg Math.cos and Math.sin. I was under the impression that I did not need to include anything for these to work. Indeed I compiled and ran these on my laptop. but then when I tried to compile same source on another machine, the compiler complained that it didn know what Math.cos was!! is this something to do with a wrong CLASSPATH settign?


2) I have done a bit of C++ int he past and rememebr the concep or passing an object either as a copy, as a pointer or by reference. - ie. either creatign a copy of an object in the called procedure that does not then effect the original object, or making that the actions perfomed in the procedure happen to the actual object (not a copy). How does this work in java - I am aware that java got rid of pointers, but how does it treat a passed object - does it trat it as a new 'local' copy in the procedure or does it reference the original object?
 
java.lang.Math is indeed imported for free, as it were ... Check that your CLASSPATH is pointing to %JAVA_HOME%\lib and %JAVA_HOME%\jre\lib.

Objects in Java are passed by reference, not value.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top