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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T08:16:44+00:00 2026-05-23T08:16:44+00:00

I am trying to use a member variable called value in a subclass. My

  • 0

I am trying to use a member variable called value in a subclass.

My super class is called SType and my subclass is called SResource.

I have a variable in the super class SType called value

I want this to be inherited by the subclass, how do I do this. The class looks like this

public class SType {

    private String value;

    public String getValue(){
        return this.value;
    }
    public void setValue(String value){
        this.value = value;
    }
}

NOTE: I edited the question to make it more clear (given the comment below). Thanks it was a simple solution, just had to make the variable protected rather than `private

  • 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-23T08:16:44+00:00Added an answer on May 23, 2026 at 8:16 am

    In order to access a superclass variable in a subclass, it has to be declared public or protected in the super class.
    Maybe yours is private?

    When you had private String value in the child class – this is a completely new variable – it’s not the one from the parent class i.e. you have two distinct private variables (I am assuming the superclass one is private).

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

Sidebar

Related Questions

I'm trying to provide a member variable as a default value for a class
I'm trying to use member variables of a templated base class in a derived
I'm trying to write a class that has a generic member variable but is
I'm trying to use the PowerShell Add-Member cmd on all the items in an
I'm trying to use XML documentation on the members of a class, and in
i am trying to use this code: <%= File.ReadAllText(Server.MapPath(Members/newsletters/welcome.html))%> which works great but now
Trying to use an excpetion class which could provide location reference for XML parsing,
Trying to use this method (gist of which is use self.method_name in the FunnyHelper
I have some code where I am trying to use variables in a tabpage.
I am trying to reference to a class variable which is a vector and

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.