Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: why this code does not give any output .

  1. #1
    Junior Member
    Join Date
    Apr 2020
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default why this code does not give any output .

    class Box {
    double width;
    double height; //instance variable
    double depth;


    double volume() {
    return width*height*depth;
    }
    void setDim(double w, double h, double d) {
    width =w;
    height =h;
    depth=d;

    }

    }

    class BoxDemo {
    public static void main(String[] args) {


    Box mybox1 = new Box(); //here created two box object.
    Box mybox2 = new Box();
    double vol;

    // assign value to instance

    mybox1.setDim(10,20,15);
    mybox2.setDim(3, 6, 9);

    vol = mybox1.volume();
    System.out.println(vol);
    vol= mybox2.volume();
    System.out.println(vol);





    }

    }

  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: why this code does not give any output .

    What happens when you compile and try to execute the program?

    Please edit your post and wrap your code with code tags:

    [code]
    **YOUR CODE GOES HERE**
    [/code]

    to get highlighting and preserve formatting.
    If you don't understand my answer, don't ignore it, ask a question.

Similar Threads

  1. I can't give input a file by console , is there any wrong in my code ??
    By devils in forum What's Wrong With My Code?
    Replies: 7
    Last Post: September 30th, 2014, 06:42 AM
  2. can someone give a code example of deleting data to a text file?
    By Nathanlll in forum What's Wrong With My Code?
    Replies: 3
    Last Post: September 15th, 2013, 06:40 AM
  3. plz give me java program for this code
    By rajesh6866 in forum What's Wrong With My Code?
    Replies: 3
    Last Post: December 3rd, 2012, 01:59 PM
  4. Replies: 2
    Last Post: July 7th, 2011, 03:46 PM
  5. The java-output doesn't give the right result?
    By pinotje in forum What's Wrong With My Code?
    Replies: 8
    Last Post: May 31st, 2011, 01:00 PM