Android Passing Variable doesn't seem to click -


i have created random number , pass along use in same file different class. please help:

public void start() { int number = random.nextint(3); // gives number such 0 <= number < 2 

then few lines down try use number it's telling me it's not variable use:

    public void renderbackground(canvas canvas) {      //todo: may wish change background colors here     if(number=="0") { 

any kind of great appreciated!

the problem facing because of scope of variable number. i'm not sure using inner class or separate class.

if it's inner class, declare number @ top of first class like,

class firstclass {   public int number; // scope public can accessed anywhere in class     method();    ...    ... class secondclass {    method()   {      system.out.println("your number : " + number); // here accessing variable `number`   }  } } 

also, try change

if(number=="0") {    if(number==0) {  

Comments

Popular posts from this blog

jquery - How do you format the date used in the popover widget title of FullCalendar? -

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -