Home > Back-end >  Dear leaders, how to solve this little sprout new said too hard
Dear leaders, how to solve this little sprout new said too hard

Time:10-01

/* 1, write a class Point, member variables including int variable x, and y; Float type variable a, b; Static int variable z;
Write method setValue (int m, int n) is a member variable x, y assignment,
Write method setValue (float a, float b) is a member variable a, b value assignment.
Complete the static method output all members () outputs the value of the variable; (this) */

CodePudding user response:

Are you coming water post?
 public class Point {
Int x, y;
Float a, b;
Static int z=5;
Public void setValue (int m, int n) {
X=m;
Y=n;
}

Public void setValue (float a, float b) {
Enclosing a=a;
This. B=b;
}

Public void the output () {
System. The out. Println (" x="+ x +", y="+ y +", a="+ a +", b="+ b +", z="+ z);
}
}




 public class Test {
Public static void main (String [] args) {
Point Point=new Point ();
Point. SetValue (1, 2);
Point. The setValue (4.0 3.0 f, f);
Point. The output ();
}
}

CodePudding user response:

reference 1st floor IHaveNoHair response:
you post is water?
 public class Point {
Int x, y;
Float a, b;
Static int z=5;
Public void setValue (int m, int n) {
X=m;
Y=n;
}

Public void setValue (float a, float b) {
Enclosing a=a;
This. B=b;
}

Public void the output () {
System. The out. Println (" x="+ x +", y="+ y +", a="+ a +", b="+ b +", z="+ z);
}
}




 public class Test {
Public static void main (String [] args) {
Point Point=new Point ();
Point. SetValue (1, 2);
Point. The setValue (4.0 3.0 f, f);
Point. The output ();
}
}
student party to what the teacher says and not fine not only ask bosses cough up but then a static method in front of the output without any static

CodePudding user response:

Upstairs to write wrong, static methods for static, your teacher may want you to learn the difference between static and constant, and then out of the question, static life cycle and common variable is not the same, you can search
  • Related