Jump to content

5 posts in this topic

Recommended Posts

Posted (edited)

it is valid tho...

I don't know in which language, but it is not valid Java code.

You close the class directly after declaring the girlName variable, then you have every function outside the class. Also, there's a function tuna without a return type specified.

I don't want to start an argument here and also find the comic funny, but that's how it is. :D

 

//edit: The code would have to look something like this to compile and work:

class Woman {
    private String girlName;

    Woman(String name) {
        girlName = name;
    }

    public void setName(String name) {
        girlName = name;
    }

    public String getName() {
        return girlName;
    }

    public void saying() {
        System.out.printf("your best girlfriend was %s\n", getName());
    }
}

class Ex {
    public static void main(String[] args) {
        Woman object = new Woman(null);
        object.saying();
    }
}
Updated by Bummibaer
×
  • Create New...

Important Information

We would like to place cookies on your device to help make this website better. The website cannot give you the best user experience without cookies. You can accept or decline our cookies. You may also adjust your cookie settings. Privacy Policy - Guidelines