Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class PassingObjects {
- double height;
- double width;
- double length;
- public PassingObjects(double height, double length, double width) {
- this.height = height;
- this.width = width;
- this.length = length;
- }
- public PassingObjects(PassingObjects obj) {
- height = obj.height;
- length = obj.length;
- width = obj.width;
- }
- public void calculateVolume() {
- System.out.println(this.length * this.width * this.height);
- }
- public static void main(String[] args) {
- PassingObjects obj = new PassingObjects(30, 40, 10);
- PassingObjects obj2 = new PassingObjects(obj);
- obj.calculateVolume();
- obj2.calculateVolume();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement