#Is this true?
1 messages · Page 1 of 1 (latest)
<@&987246399047479336> please have a look, thanks.
Here is an AI assisted attempt to answer your question 🤖. Maybe it helps! In any case, a human is on the way 👍. To continue talking to the AI, you can use </chatgpt:1108714622413963314>.
No, this statement is not true. In Java, if a class is declared as public, it means that it can be accessed by any other class, regardless of whether they are in the same package or not. However, the visibility of variables within a class depends on their access modifiers.
By default, if no access modifier is specified for a variable (also known as package-private or default access), it can be accessed by other classes within the same package. If you want to make a variable accessible to classes outside the package, you need to explicitly declare it as public.
To import a class in Java, you don't need to make its variables public. Importing a class simply allows you to use its methods and variables without specifying the fully qualified name each time. The accessibility of variables within the class itself is determined by their access modifiers.
thats why u have access modifiers and getters / setters
the visibility of the class doesnt affect visibility of its fields
if u omit the access modifier, it implicitly means package-visible
not only for fields, also for methods or classes
I'm a lil' confused. Does this mean the statement is technically true, but only because the visibility of those two things aren't connected to each other?
yeah
Ok thanks!
How do i tag this problem as solved or does this server have such a feature?
let me do it
Closed the thread.
Thanks
oh ahahs
2min cooldown