June 2018
Beginner
722 pages
18h 47m
English
We talked about interfaces in Chapter 2, Java Language Basics, so now we will just look at some examples. Let's create a new package, com.packt.javapath.ch06demo.api. Then, we can right-click com.packt.javapath.ch06demo.api, open New | Java Class, select Interface, type Calculator, and click the OK button. We have created an interface and can add to it a method signature, int multiplyByTwo(int i), so the result looks like this:

This will be the public face of every class that implements this interface. In real life, we would not use the package name api and use calculator instead, as it is more specific and descriptive. But we are ...
Read now
Unlock full access