Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 6 of 6

Thread: CREATING NESTED CLASSES

  1. #1
    Junior Member
    Join Date
    Apr 2013
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default CREATING NESTED CLASSES

    i have decided to create three classes, branch_off, employee, and head_off to manage the details of the employees as required by the company.i want to design these classes to ensure that employee class is accessed only by branch_off and not by head_off? help me provide the required code for it.


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: CREATING NESTED CLASSES

    If you don't understand my answer, don't ignore it, ask a question.

  3. #3
    Junior Member
    Join Date
    Apr 2013
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: CREATING NESTED CLASSES

    i have tried it by making the Employee the superclass, and their members are protected. With the branch_off i extended the functionality of the employee class which is inheritance then the last class which is the head_off is left out.

  4. #4
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: CREATING NESTED CLASSES

    What were the problems?
    If you don't understand my answer, don't ignore it, ask a question.

  5. #5
    Junior Member
    Join Date
    Apr 2013
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: CREATING NESTED CLASSES

    i want to know if there is a way i can include all classes in the same body.

  6. #6
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: CREATING NESTED CLASSES

    include all classes in the same body
    If by "body" you mean source file. A source file can contain many class definitions. Only one of the classes can be public and the filename should match the name of the public class.
    If you don't understand my answer, don't ignore it, ask a question.

Similar Threads

  1. Replies: 6
    Last Post: October 31st, 2012, 06:16 AM
  2. Nested classes.
    By atar in forum Object Oriented Programming
    Replies: 11
    Last Post: May 2nd, 2012, 05:28 PM
  3. Creating classes with generic objects
    By rbt in forum Collections and Generics
    Replies: 2
    Last Post: April 23rd, 2012, 08:08 PM
  4. Question about creating and using classes.
    By iDizzle in forum Object Oriented Programming
    Replies: 20
    Last Post: April 1st, 2012, 03:14 PM
  5. Creating and implementing class for creating a calendar object
    By kumalh in forum Object Oriented Programming
    Replies: 3
    Last Post: July 29th, 2011, 08:40 AM