How can I put the variables of "ab, bc, cd, & da" of dsada() method into the 123132 method without copying and pasting? (the *dsada** method also has a method from distance inside it too)
The scope of the variables is limited to order
method and there's no way you can access them inside isSquare
method like you have used unless
1- You pass those variables as arguments in to isSquare
method
2- Or declare an array
inside order
method, place all the variables in that array and then pass that array as an argument in to isSquare
method. You could also return this array from order
method.
3- Or instead of declaring those variables inside order
method, make them class level variables. When declared as class level variables, every method inside that class will have access to those variables.
You should save those variables in the class scope. Declare the variables, and make sure you initiallize them before you use them otherwise you'll get a NullPointerException.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.