Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class RunCircle {
- public static void main(String[] args) {
- Circle c1;
- Circle c2;
- // new circle with radius 1.0
- c1 = new Circle();
- // new Circle with radius 7.0
- c2 = new Circle(7);
- // print radius of each circle
- System.out.println(c1.getRadius());
- System.out.println(c2.getRadius());
- // print c1 area
- System.out.println(c1.getArea());
- // print c2 area
- System.out.println(c2.getArea());
- // set radius to 5 for both circles
- // c1.setRadius(5);
- c2.setRadius(5);
- // print radius of each circle
- System.out.println(c1.getRadius());
- System.out.println(c2.getRadius());
- // c1 and c2 are different objects
- if (c1 == c2) {
- System.out.println("Equal");
- } else {
- System.out.println("Not Equal");
- }
- Circle c3 = c1;
- // c1 and c3 points to the same object
- if (c1 == c3) {
- System.out.println("Equal");
- } else {
- System.out.println("Not Equal");
- }
- // print circle data
- System.out.println(c1);
- System.out.println(c2);
- System.out.println(c3);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement