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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T15:10:15+00:00 2026-05-16T15:10:15+00:00

I have questions about inheriting(extending) methods from classes and hiding some classes and methods

  • 0

I have questions about inheriting(extending) methods from classes and hiding some classes and methods from the main 🙂

Assume that I have class A & class B. Class B has method 1. and I need to use that method(method 1) in class A, but in the same time I need to hide that class(Class B with its methods) from the main.

I mean I want to deal with method 1 only from class A(or any other additional class, let’s say Class C) I don’t want it to be seen in the main. I don’t want to give the possibility for the main to create an instance from Class B to use method 1. I need to do that, because when I create a jar file for my classes, there are classes that have methods that I don’t want them to be shown. These classes I used them only when I did create the jar file.

How I can hide these classes and methods ?? I hope my explanation is clear…

Please don’t tell me to do these things, because I thought of it, and it doesn’t works : 🙂

1) to use private for the methods that I don’t want them to be shown, because I can’t do that. since, it’s a separated classes not in the same class, and when I put private near the function , I can’t use it at all, only it will works with the same class.

Also,

2) To put all the functions in the same class, Because I need to organize my code with classes with a separated files 🙂

Thanks alot Guys ….

  • 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-16T15:10:16+00:00Added an answer on May 16, 2026 at 3:10 pm

    You can solve your problem by using different packages for your classes:

    Put your class containing the main() method into package m.
    Then put class A in package a and make it public.
    Put class B in package a, too and make it only package protected (skip the public key word).

    Now you can access class A from your main(), but you can’t access class B.

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

Sidebar

Related Questions

I want to write a custom class that behaves like dict - so, I
A little background I'm working on an .net application that's uses plugins heavily, the
I am currently developing a new WPF application and have the majority of my
Little question concerning app architecture: I have a python script, running as a daemon.
I am building an ASP.NET web application that will use SQL Server for data
I am trying to render an openGL es surface from the NDK, but got
My two questions are: Can I use clustered indexes to speed up bulk inserts
I'm inserting some items into array with randomly created indexes, for example like this:
I want to use protobuff in a Java application to facilitate serialization and I
I'm inserting lot of data with a SqlBulkCopy. The source of the data may

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.