B
biner
Hello,
I have two questions. One about variable scope and the other regards
using java on xdarwin.
I would like to pass a variable to an object of a given class with
the constructor and I would like that variable to be visible by the
methods of that class. To illustrate, here is the output I get from
the code that follows :
*** begin output ***
[sbiner:~/CODE/java/src] biner% java testVariableScope
const maClase, toto=10.0
const maClase, toto2=10.0
montre Toto, toto=0.0
montre Toto, toto2=10.0
*** end output ***
*** begin code ***
class maClasse {
double toto ;
double toto2 ;
// constructeur
maClasse(double toto) {
toto2=toto ;
System.out.println("const maClase, toto="+toto) ;
System.out.println("const maClase, toto2="+toto2) ;
}
// methode montre Toto
void montreToto() {
System.out.println("montre Toto, toto="+toto) ;
System.out.println("montre Toto, toto2="+toto2) ;
}
}
public class testVariableScope {
// main
public static void main(String[] args) {
double toto = 10. ;
maClasse titi = new maClasse(toto) ;
titi.montreToto() ;
}
}
*** end code ***
I would like the montreToto method to "see" the right value of toto
without having to copy toto in toto2. And I don't understand why toto2
is "viewed" and not toto. Anybody can give me a pointer ?
The other question has to do with XDarwin. Using java on Xdarwin, I
would like for the windows oppened by java (and the appletviewer) to
be opened in X and not in OSX. Is there a way to do this? It is a bit
of a pain to constantly change between XDarwin for programming and
compiling and OSX to see the results.
Any help with these question would be appreciated.
Thank you
Sebastien
(e-mail address removed)
*****************************
I have two questions. One about variable scope and the other regards
using java on xdarwin.
I would like to pass a variable to an object of a given class with
the constructor and I would like that variable to be visible by the
methods of that class. To illustrate, here is the output I get from
the code that follows :
*** begin output ***
[sbiner:~/CODE/java/src] biner% java testVariableScope
const maClase, toto=10.0
const maClase, toto2=10.0
montre Toto, toto=0.0
montre Toto, toto2=10.0
*** end output ***
*** begin code ***
class maClasse {
double toto ;
double toto2 ;
// constructeur
maClasse(double toto) {
toto2=toto ;
System.out.println("const maClase, toto="+toto) ;
System.out.println("const maClase, toto2="+toto2) ;
}
// methode montre Toto
void montreToto() {
System.out.println("montre Toto, toto="+toto) ;
System.out.println("montre Toto, toto2="+toto2) ;
}
}
public class testVariableScope {
// main
public static void main(String[] args) {
double toto = 10. ;
maClasse titi = new maClasse(toto) ;
titi.montreToto() ;
}
}
*** end code ***
I would like the montreToto method to "see" the right value of toto
without having to copy toto in toto2. And I don't understand why toto2
is "viewed" and not toto. Anybody can give me a pointer ?
The other question has to do with XDarwin. Using java on Xdarwin, I
would like for the windows oppened by java (and the appletviewer) to
be opened in X and not in OSX. Is there a way to do this? It is a bit
of a pain to constantly change between XDarwin for programming and
compiling and OSX to see the results.
Any help with these question would be appreciated.
Thank you
Sebastien
(e-mail address removed)
*****************************