# Package-level and public members of a class without internal. Is it possible?

**URL:** <https://discuss.kotlinlang.org/t/package-level-and-public-members-of-a-class-without-internal-is-it-possible/4947>\
**Category:** Uncategorized\
**Created:** [October 11, 2017, 5:05am UTC](https://discuss.kotlinlang.org/t/package-level-and-public-members-of-a-class-without-internal-is-it-possible/4947 "2017-10-11T05:05:50Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Antonel.Ernest.Pazargic](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.kotlinlang.org/antonel.ernest.pazargic/32/3608_2.png) [@Antonel.Ernest.Pazargic](https://discuss.kotlinlang.org/u/Antonel.Ernest.Pazargic)\
**Post date:** [October 11, 2017, 5:05am UTC](https://discuss.kotlinlang.org/t/package-level-and-public-members-of-a-class-without-internal-is-it-possible/4947/1 "2017-10-11T05:05:50Z")

</div>

Dear kotlin community,

Recently I started to create a simple DSL on top of apache POI.  
And I came across the problem of not being able to author classes for which some members have package level visibility and others public one, as per below:

**Before conversion**

```
 public class Foo {

  public void foo1() {
    System.out.println("foo1");
  }

  void foo2() {
    System.out.println("foo2");
  }
}

```

**After conversion**

```
    class Foo {

        fun foo1() {
            println("foo1")
        }

        internal fun foo2() {
            println("foo2")
        }
    }

```

I’ve read some kt conversations on this topic, and one of the solutions was to have all classes with the package level visibility members in the same file.  
I did this but it seems that in that case I cannot mix package level and public level members in the same class.  
Is there a good approach for addressing this w/o having internal visibility and another module?

Thank you in advance for your support.

Tony

---

<div class="post-metadata">

**Author:** ![vbezhenar](https://avatars.discourse-cdn.com/v4/letter/v/35a633/32.png) [@vbezhenar](https://discuss.kotlinlang.org/u/vbezhenar)\
**Post date:** [October 11, 2017, 9:37am UTC](https://discuss.kotlinlang.org/t/package-level-and-public-members-of-a-class-without-internal-is-it-possible/4947/2 "2017-10-11T09:37:36Z")

</div>

By default Kotlin’s visibility is `public`. `internal` corresponds (more or less) to Java’s package-level visibility (it’s more visible actually, but it shouldn’t be a problem).

---

<div class="post-metadata">

**Author:** ![Antonel.Ernest.Pazargic](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.kotlinlang.org/antonel.ernest.pazargic/32/3608_2.png) [@Antonel.Ernest.Pazargic](https://discuss.kotlinlang.org/u/Antonel.Ernest.Pazargic)\
**Post date:** [October 11, 2017, 1:51pm UTC](https://discuss.kotlinlang.org/t/package-level-and-public-members-of-a-class-without-internal-is-it-possible/4947/3 "2017-10-11T13:51:41Z")

</div>

Hi vbezhenar,

Thank you for your reply.

> [@vbezhenar](#):
>
> internal corresponds (more or less) to Java’s package-level visibility (it’s more visible actually, but it shouldn’t be a problem)

internal visibility modifier acts more or less like package one if the classes containing internal members resides in a different module.  
In my case the classes acts like a basic/small API with internals (internal members) and an exposed interface (public members).  
The main requirement for my API is to reside in the same module as its only client.  
I can’t tell to the code reviewer I have to create a new module for this tiny API just to handle this case.

Thank you in advance for helping me in this matter.

Tony
