Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7822693
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T07:59:45+00:00 2026-06-02T07:59:45+00:00

Is it possible to reference Java types with a partially qualified name? If so,

  • 0

Is it possible to reference Java types with a partially qualified name? If so, how?

The scenario: I frequently find myself with a data class (e.g. Activity) which needs a view. My standard practice has been to name this class ActivityView, which works, but this view class invariably ends up in a tld.organization.project.views namespace, where the “View” suffix is entirely redundant.

I’d like to remove “View” suffix (so the types would be tld.organization.project.Activity and tld.organization.project.views.Activity), but this means I must use the namespace to qualify the types when I reference them in the same class. Using the namespace to qualify type references is not a bad thing in and of itself, but repeating the fully qualified name of either type is repetitious and difficult to read.

Referencing a partially qualified type (something like ~.Activity or ~.views.Activity) would remove that cruft. Some kind of type aliasing would answer, but it appears Java doesn’t support such functionality. Are there any alternatives?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T07:59:46+00:00Added an answer on June 2, 2026 at 7:59 am

    No, you can’t do that with packages in Java. The closest you could get would be to organize things into nested hierarchies of classes instead of packages. Between that and strategic static importing, you could get the desired effect, though it would be a terribly messy solution. For example:

    package tld.organization.project;
    public class Activity {}
    

    and:

    package tld.organization.project;
    public class Views {
        public static class Activity {}
    }
    

    which can then be referred to as:

    public void whatever() {
        Activity a = new Activity();
        Views.Activity a2 = new Views.Activity();
    }
    

    I’d suggest that the problems you’re having with names may be pointing to a design problem that needs to be sorted out.

    P.S. If I ever had to work on a project that organized classes so, I might have to shoot myself.

    P.P.S. Actually, I’d probably try to shoot you first.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: Storing primitive values in a Java collection? ArrayList accepts only reference types
Possible Duplicate: Is Java pass by reference? public class myClass{ public static void main(String[]
Possible Duplicate: Reference unit tests for common data structures? I'm trying to implement the
Possible Duplicate: Returning reference to a local variable I happened to find this code
Is it possible to narrow the type of a field in a Java class
Possible Duplicates: What's the difference between passing by reference vs. passing by value? Java
It is possible in Java to do sth like: Class packageName1.foo extends packageName2.foo {
Is it possible to somehow 'import' a new Java class into a running program
Possible Duplicate: Java pass by reference issue In my codes below, methodA will be
Is this possible converting R.java variable to URI reference? What can be URI? PS:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.