consider

public class awah{
private int x=0;
private int y;
private int w;

public awah(int width){
w=width;
}
public void sety(){
y=(Int)(Math.random()*4);}//meth1

public int gety(){
return y;
}

public void setx (){
x+=this.gety();
}

public int getx(){
return x;
}

public void showUpdate(){
System.out.println(x);
}

}//end of awah

public static void main(String[] args){
    awah m  = new awah(5);
    m.showUpdate();
}

I expected the update to show the updated value of x+y but it doesn't
I want to be able to update the variable x whenever y is set to some random number
//frustrated

Line 10, do you have your own implemented of class Int? It should be int, not Int. Remember that all variable/class names Java are case-sensitive.

PS: You have not done anything with the variable you created in your main() but expect the value to be updated???

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.18 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.