Senin, 30 Januari 2017

How to use variables in Interfaces (Java Programming)

An interface can contain constants (final variables). A class that implements an interface containing constants can use them as if they were declared in the class. Example demonstrating constants in an interface is given below: IArea.java (interface) 1 2 3 4 public interface IArea { double PI = 3.142; }   Driver.java (Main program which implements the above interface) 1 2 3 4 5 6 7 public class Driver implements IArea { public static void main(String args) { System.out.println(“PI value is: “ + PI); } } In the above code the class Driver.java implements the interface IArea and prints the value of the

The post How to use variables in Interfaces (Java Programming) appeared first on Coding Security.


How to use variables in Interfaces (Java Programming)
read more

Tidak ada komentar:

Posting Komentar