user2305415
user2305415

Reputation: 172

In java, about access modifiers, what the word "world" means?

I've seen here on stackoverflow a post where there was this simple and clear summary about access modifiers in java. I understand all but just one thing is weird :what the word "World" stands for ? What does it mean?

I have delete the display of the schema summary because the render was weird :s So please look at the link below >>>

Here is the link of the post: In Java, difference between default, public, protected, and private

Thks in advance!

Upvotes: 2

Views: 2472

Answers (3)

Santa
Santa

Reputation: 11545

It means if I have a class like:

package com.example;

public class Foo {
    public int bar;
}

I can access it from "outside" in the most general meaning of the word, like:

package com.client;         // not in the same package of `Foo`

class Client {              // not a subclass of `Foo`
    Foo foo = new Foo();    // possible because `Foo` is world-visible
    public int foobar() {
        return foo.bar;     // possible because `bar` is world-visible
    }
}

Upvotes: 1

durron597
durron597

Reputation: 32343

World means you can call that method, or access that field or class no matter where the code is written, no matter the packaging, subclass, and so forth.

It could even be "universe" if you prefer.

Upvotes: 0

Tetsujin no Oni
Tetsujin no Oni

Reputation: 7375

"World" is the visibility description when using non-reflection references from outside the package, as in a library reference.

Upvotes: 0

Related Questions