create account

ANOTHER WAY OF WORKING WITH INTERFACE IN JAVA by leoumesh

View this thread on: hive.blogpeakd.comecency.com
· @leoumesh ·
$2.25
ANOTHER WAY OF WORKING WITH INTERFACE IN JAVA
For the post on interface, please click [here](). There are many ways to work with interface in java basically to remove the unnecessary code. Here's a program to showing two of these.

```
package Polymorphism;

interface A{
	void output();
}

public class InterfaceClassLambda {

	public static void main(String[] args) {
		A obj=new A(){
			public void output() {
				System.out.println("Hello World");
			}
		};
		obj.output();
	}

}

```

<br>

Or you can work with interface through a mechanism known as Lambda Expression, where you can create function without requiring a class.

```
interface A{
	void output();
}

public class InterfaceClassLambda {

	public static void main(String[] args) {
		A obj= () ->
				System.out.println("Hello World");
			
		obj.output();
	}

}
```

Both will show the same output when executed.
👍  , , , , , , , , , , , , , , , , , , ,
properties (23)
authorleoumesh
permlinkanother-way-of-working-with-interface-in-java
categoryhive-122108
json_metadata{"tags":["hive-122108","java","coding","porgramming","code","education","tutorial","oops"],"app":"hiveblog/0.1","format":"markdown"}
created2020-07-07 15:18:30
last_update2020-07-07 15:18:30
depth0
children1
last_payout2020-07-14 15:18:30
cashout_time1969-12-31 23:59:59
total_payout_value1.227 HBD
curator_payout_value1.020 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length832
author_reputation212,340,493,251,438
root_title"ANOTHER WAY OF WORKING WITH INTERFACE IN JAVA"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id98,391,385
net_rshares7,311,097,149,890
author_curate_reward""
vote details (20)
@gitplait-mod1 ·
Thanks for sharing an other Java tutorial. I would request you to share your previous link in new post as it will be helpful for java enthusiast to see your other amazing tutorial. 

<sub> Your post has been submitted to be curated with @gitplait community account because this is the kind of publications we like to see in our community. </sub>

Join our [Community on Hive](https://hive.blog)
properties (22)
authorgitplait-mod1
permlinkqd3uyp
categoryhive-122108
json_metadata{"users":["gitplait"],"links":["https://hive.blog"],"app":"hiveblog/0.1"}
created2020-07-07 15:28:03
last_update2020-07-07 15:28:03
depth1
children0
last_payout2020-07-14 15:28:03
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length394
author_reputation64,455,719,431
root_title"ANOTHER WAY OF WORKING WITH INTERFACE IN JAVA"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id98,391,530
net_rshares0