Advertisement
Guest User

Untitled

a guest
Feb 11th, 2016
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.73 KB | None | 0 0
  1. public class PassingObjects {
  2.  
  3. double height;
  4. double width;
  5. double length;
  6.  
  7. public PassingObjects(double height, double length, double width) {
  8. this.height = height;
  9. this.width = width;
  10. this.length = length;
  11. }
  12.  
  13. public PassingObjects(PassingObjects obj) {
  14. height = obj.height;
  15. length = obj.length;
  16. width = obj.width;
  17.  
  18. }
  19.  
  20. public void calculateVolume() {
  21. System.out.println(this.length * this.width * this.height);
  22. }
  23.  
  24. public static void main(String[] args) {
  25. PassingObjects obj = new PassingObjects(30, 40, 10);
  26. PassingObjects obj2 = new PassingObjects(obj);
  27.  
  28. obj.calculateVolume();
  29. obj2.calculateVolume();
  30.  
  31.  
  32. }
  33.  
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement