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.

  • Re: General CS concepts

    Another note to interfaces.

    When you have an interface declared like this.

    public interface Doable
    {
         int myInt = 10;
         boolean canDoIt1();
         int doIt2(int num);
    }

    The code will implicitly look like this.

    public interface Doable
    {
         [b]public static final[/b] int myInt = 10;
         [b]public[/b] boolean canDoIt1();
         [b]public[/b] int doIt2(int num);
    }

    Notice that any variables declared in the interface will become static and final because you can only define constants on an interface.

    According to the rules of implementation the first concrete class has to implement the interface. This means that abstract classes do not have to implement the methods on the interface.

    public abstract class DoStuff implements Doable {
     
    }

    // Json
    This article was originally published in forum thread: General CS concepts started by helloworld922 View original post