Why does my code doesn't work?


class Coffee extends Beverage {
    public Coffee() {

    public void addSugar(int cubes) {

        System.out.println("You added " + cubes + " sugar cubes.");


    public static void main(String[] args) {
    Coffee myOrder = new Coffee();



The code looks ok. Do you get any errors? Check Beverage class, maybe there is some kind of problem but if there any kind of problem in will be only on this line: myOrder.isFull(); for method isFull();


I am going to have to agree with perk-one, the code looks fine.
Also perk-one is correct in asking, did you get an error?


No. There is no such error but it says the problem is that the object "myOrder" is not created inside the main method.
I have a doubt..do i have to create the object in class "coffee" or class "beverage" ?


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.