Skip to main content

All Questions

Tagged with
0 votes
0 answers
151 views

What are the visibility rules for package com.sun.tools.javac.code in oracle open jdk version 20?

I am writing a database management program in java in maven in intellij IDEA. For now, the code is only connecting me to the database in MySQL. The code itself has no errors. However, upon running it, ...
amama's user avatar
  • 1
1 vote
1 answer
653 views

WHY Java doesn't have the concept of Subpackage visibility [duplicate]

Java doesn't have the concept of Subpackage visibility I know that :( Java: Subpackage visibility? so if I have a Class A (package visible) inside the package com.example.foo and another Class B (...
gixlg's user avatar
  • 1,313
1 vote
2 answers
141 views

Can I use packages without making all of the methods/ attributes public?

I have a project with about 10 classes. I moved some classes to a package for clarity. Is there a safe way to connect between classes without data leaks? -using public is dangerous because anyone can ...
benjamin's user avatar
  • 353
0 votes
0 answers
57 views

Unable to create instance of class in sub-package

Why I can not create in class KeyboardController instance of Frame like: Frame frame=new Frame(); It is not recognized by IDEA. Is it because classes in lower package can not see and work with ...
victory's user avatar
  • 185
4 votes
1 answer
2k views

How to work around that there's no subpackage visibility in Java

When I'm writing a new component with DDD I try to have one single public class in a package with all collaborators of my component package protected. That usually plays out very nicely, because ...
Stefan Haberl's user avatar
0 votes
1 answer
301 views

Why can't I call a package-private method of another class that's a subclass of a class in the same package?

I have a class Base in package A that defines the package-private method foo(). In package B, I have a class Impl that extends Base. In package A, if I try to call foo() on an instance of Impl, I ...
codebreaker's user avatar
1 vote
2 answers
61 views

Java: protected, visibitily [duplicate]

I'm a bit confused about the whole protected thing in java. If something is protected only the classes within the same package can access it, right? Should we use protected private attributes in a ...
user8716414's user avatar
1 vote
1 answer
21 views

Hiding libs packages to implementators

Am writing a lib where I have a package with several classes inside, one of this classes is the final class Point( that is used by many other classes but has no public access outside its package in ...
ΦXocę 웃 Пepeúpa ツ's user avatar
1 vote
0 answers
40 views

Design package hierarchy in java, visibility constraints [duplicate]

I have a package ts, containing interfaces for ticket system. I also have hts package, containing concrete implementation of ts. I have TicketSystem.class in ts, and HTicketSystem.class in hts ...
Andrey's user avatar
  • 907
1 vote
1 answer
866 views

Accessing top level classes from within a Java package

Say we have a project located at folder project with the sources in project/src. We have a package package at project/src/package and classes TopClass in project/src/TopClass.java, and PackageClass ...
k.stm's user avatar
  • 200
2 votes
4 answers
7k views

How to get class'es method without importing class

There is a situation: package pak1 contains some class package pak1; public class A { public void g() {} } and another package pak2 package pak2; public class B { public void f() { ...
Edison Miranda's user avatar
0 votes
2 answers
8k views

How to access a protected variable from another package

Here I want to access that protected variable rollno to my another package package2. So guys I have put both programs: So here when I run Check.java it throws an error not defined @ Protected1 the ...
user3522245's user avatar
0 votes
2 answers
741 views

Eclipse - I want to access a class from the same package but under a different project, how?

I use Eclipse IDE for my Java projects and all my projects(Project_1,Project_2 and so on) related classes are inside a package package_name. I am currently working on 2 classes. class_name.java(...
Keir Simmons's user avatar
  • 1,674
0 votes
1 answer
158 views

Eclipse Java: using existing source-code as different packages (due to visibility)

I have 3 different Java-projects: Project A: some basic functionality (Package: "com.a.b.c") Project B: should be a library and uses A (Package: "com.b.c.d") Project C: should be a library and uses A ...
user2742923's user avatar
0 votes
0 answers
354 views

Is it possible to make an interface extendable without it being implementable?

To make what I think is a reasonable analogy, suppose I have a "drink" interface. I can fill it, dump it, and maybe do some other things. I need to know how many people are drinking this drink before ...
WhatsInAName's user avatar

15 30 50 per page