+ 2
Please solve my error
3 ответов
+ 2
you should use 'this' keyword to access instance properties (wich should be defined in the class):
public class Box10 {
int x;
int y;
public void getdata() {
Scanner input = new Scanner(System.in);
System.out.println("enter two numbers");
this.x = input.nextInt();
this.y = input.nextInt();
}
public void showdata() {
System.out.println("the entered number"+this.x);
System.out.println("the entered number:"+this.y);
}
}
+ 2
Kajal Kumari
int x and int y declared local variable. You can't access in another method.
+ 2
Thanks