Login  Register

Re: return value

Posted by Volker Baecker on Mar 03, 2009; 5:17pm
URL: http://imagej.273.s1.nabble.com/Can-t-load-images-from-remote-directory-tp3693495p3693501.html

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi,
just to avoid confusion for newcomers, the variables you propose to use
are called instance variables. Class variables are static variables. See
for example here:
http://java.sun.com/docs/books/tutorial/java/javaOO/classvars.html
Volker

Thomas Boudier a écrit :

> Hi,
>
> Put your x,y,z values as class variables so they can be read everywhere
> (an do not forget to supress the declaration in the function myread) :
>
> class mean3DXYZ {
>
> int x,y,z;
>
> public int myread (String string) {
>
> DO NOT WRITE int x ....
>
> }
>
>
>
> Thomas
>
>
>
>
> m000an ZH a écrit :
>> Hi, just a very easy question.
>> I return a value x with myread.
>> how can I use this value in an other method to use it in "run"?
>> Thanks for your help
>> Milan
>>
>>
>>
>>
>> public int myread (String string) throws Exception {
>>
>> StringTokenizer st = new StringTokenizer (string, "\t");
>>
>> int count = st.countTokens ();
>>
>> int xyz[];
>>
>>
>> int x;
>>
>> count = (count> 3) ? 3 : count;
>>
>> for (int l = 0; l < count; l++) {
>>
>> String token    = st.nextToken ().trim ();
>>
>> xyz [l] = (new Integer (token)).intValue ();
>>
>> x = xyz [0];
>>
>> }
>>
>> return x;
>>
>> }
>>
>> public void run (ImageProcessor ip) {
>> int i = myread ();
>>
>> tab = col.getNeighborhoodSphere (i, 2, 3, rad, rad, rad);
>> }
>> _________________________________________________________________
>> Découvrez toutes les possibilités de communication avec vos proches
>> http://download.live.com
>>
>
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFJrWYsxZKX7A/4oMERAr+VAJ0WJPp55WFcsxhm12s9guda6BbJDgCgyzhI
5lUXMR5Ts6UUqKSAVVkmBJU=
=NA70
-----END PGP SIGNATURE-----

--
passerelle antivirus du campus CNRS de Montpellier
--