On Saturday, 19 May 2018 at 08:32:28 UTC, Uknown wrote:

I ported your example to Java. Surprisingly, it compiled and executed just fine:

All I see, is a class, with static members. How else would it work?

This is the equivalent of my D example, in Java:

( it won't even compile.  phew!  )

--------------
public class test
{
    public static void main(String[] args)
    {
        Dog dog = new Dog();
        dog.noiseType = "meow";              // no way jose
System.out.println(dog.makeNoise()); // phew! cause dogs don't meow.
    }
}

class Dog
{
    private String noiseType = "woof";

    public String makeNoise()
    {
        return this.noiseType;
    }
}
--------------------

Reply via email to