FAQ
Cover
This is the archive Discourse for the Processing (ALPHA) software.
Please visit the new Processing forum for current information.

   Processing 1.0 _ALPHA_
   Programming Questions & Help
   Syntax
(Moderators: fry, REAS)
   Variable of a class
« Previous topic | Next topic »

Pages: 1 
   Author  Topic: Variable of a class  (Read 283 times)
eskimoblood

222550793222550793 WWW
Variable of a class
« on: Jan 19th, 2005, 4:18pm »

I have a class with a stringArray. I thought I can get the value of this array, outside the class, like className.arrayName[i] but it dosent work.
 
mKoser

WWW Email
Re: Variable of a class
« Reply #1 on: Jan 19th, 2005, 4:57pm »

you can access it like this:
 
Code:

MyClass myObj;
 
void setup(){
  myObj = new MyClass();
}
 
void loop(){
}
 
void mousePressed(){
  println(myObj.strArr[(int)random(0, 3)]);
}
 
class MyClass{
  String[] strArr = {"the", "brown", "fox", "jumps"};
 
  MyClass(){
  }
}

 
where every time you click, a random string is printed from the myObj's stringArray!
 
does that help?
 
+ mikkel
 

mikkel crone koser | www.beyondthree.com | http://processing.beyondthree.com
Pages: 1 

« Previous topic | Next topic »