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 554433
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T11:42:32+00:00 2026-05-13T11:42:32+00:00

Today I looked at the ZipEntry class and found the following: public class ZipEntry

  • 0

Today I looked at the ZipEntry class and found the following:

public class ZipEntry implements ZipConstants, Cloneable

ZipConstants does not define any methods – only constants (static final int LOCHDR = 30)

It then occurred to me that implementing the interface with constants lets you access those constants directly, as if they were defined in the class itself. For example:

public interface Constants {
    static final int CONST = 2;
}

public class implements Constants {
    int doSomething(int input) {
        return CONST * input;
    }
}

Is there another reason not to use this, apart from:

  • it is at first confusing where the constant is coming from
  • it is considered wrong to use interfaces for constants definition

I’m curious because it is definitely not a very common practice.

  • 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-05-13T11:42:33+00:00Added an answer on May 13, 2026 at 11:42 am

    Another reasons not to use this:

    Since Java 5, there is a “clean” language feature that achieves the same goal: static imports.

    Implementing interfaces to use constants is basically a pre-Java-5 hack to simulate static imports.

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

Sidebar

Related Questions

I looked at some Java code today, and I found some weird syntax: public
Today, I have looked into HTML code of facebook.com, and found something like this:
Later today, I was scrolling through ejhon.com slides and I found out the following:
I've already looked myself but it seems my Google-fu is not strong today. I'm
Someone asked about Lazy Binary Searches today. Not knowing what that was, I looked
I found something interesting today when opening VS2010 on my PC. It looked as
My site used to look the same in IE, Chrome, Firefox. Today, I looked
I came accross the following code today and I didn't like it. It's fairly
(I looked everywhere for this, perhaps my googling skill is off today) I have
EDIT: following the first answer I have looked more into stackoverflow and rephrased the

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.