# Explanatory examples of protocol benefits vs Java interfaces?

**URL:** <https://forums.swift.org/t/explanatory-examples-of-protocol-benefits-vs-java-interfaces/30451>\
**Category:** Using Swift\
**Created:** [November 4, 2019, 7:57am UTC](https://forums.swift.org/t/explanatory-examples-of-protocol-benefits-vs-java-interfaces/30451 "2019-11-04T07:57:01Z")\
**Posts on this page:** 1\
**Showing post:** 6

<div class="post-metadata">

**Author:** ![svanimpe](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/svanimpe/32/38963_2.png) [@svanimpe](https://forums.swift.org/u/svanimpe)\
**Post date:** [November 5, 2019, 11:35am UTC](https://forums.swift.org/t/explanatory-examples-of-protocol-benefits-vs-java-interfaces/30451/6 "2019-11-05T11:35:56Z")

</div>

> [@robnik](#):
>
> terms that I don't understand well (like "existential types")

These may be easier to understand if you don't view protocols as types. For example:

```swift
protocol Thing { }

var p: Thing

```

Instead of reading this declaration as “the type of `p` is `Thing`”, read it as “`p` can hold an instance of any type that conforms to `Thing`”.

In other words, even though you can't instantiate `Thing` because it's a protocol, there **exists** at least one type that conforms to it and whose instances you can assign to `p`.

The confusion arises because the type annotation for the existential “any type that conforms to `Thing`” is simply `Thing`. See [Improving the UI of generics](https://forums.swift.org/t/improving-the-ui-of-generics/22814#heading--clarifying-existentials) for a possible solution.

---

_[View the full topic](https://forums.swift.org/t/explanatory-examples-of-protocol-benefits-vs-java-interfaces/30451)._
