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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T11:27:49+00:00 2026-06-10T11:27:49+00:00

Are public members variables in Java 8 interfaces a feature or an implementation side-effect/defect?

  • 0

Are public members variables in Java 8 interfaces a feature or an implementation side-effect/defect?

This question pertains to the pre-release Java 8 build lambda-8-b50-linux-x64-26_jul_2012.tar.gz.

Java 8 introduces new features to interfaces in the form of default methods. Casual testing with the JDK8 lambda compiler allows interfaces of this form:

public interface Foo {
  public int foo = 0;
  int foo() default { return foo; }
}

Sample implementing type:

public class FooImpl implements Foo {
  public int foo = 1;
}

This code follows the standard conventions for variable shadowing:

Foo f = new FooImpl();
System.out.println(f.foo());
System.out.println(f.foo);
System.out.println(new FooImpl().foo);

Output:

0
0
1

The documentation (JSR 335: Lambda Expressions for the Java™ Programming Language Version 0.5.1) doesn’t mention member variables. I’m inclined to think the compiler is being too tolerant but perhaps I’ve missed something.

  • 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-10T11:27:51+00:00Added an answer on June 10, 2026 at 11:27 am

    Public fields in interfaces are not a new features in Java 8. If you remember that they are implicitly static and final, the results you are seeing make perfect sense.

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

Sidebar

Related Questions

Greetings fellow members, the situation in question is such: public abstract class BaseClass {
iI have some trouble getting sth like this to work in java: public class
I have a question regarding inheritance in Java. If I have this base class
Many Java frameworks allow class members used for injection to be declared non-public. For
This question relates to behaviour of old Java versions and old implementations of the
Does the this prefix for accessing member variables exist in Java? Here is my
MSDN says that public static members of System.Windows.Application are thread safe. But when I
Is it ok to have public data members in a C++ class/struct in certain
I have a DbContext with several of the following type of members: public DbSet<JobLevel>
public abstract class Request { public class Parameters { //Threre are no members here

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.