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 3 of 3

Thread: Java Inner Class Access

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

    Unhappy Java Inner Class Access

    package pack1;
    Public class A{
    private class B{
    int x = 10;
    public void fun1(){
    Syso("Some Data");
    }
    private void fun2(){
    //Some Data
    }
    }
    }

    package pack2;
    public class C{
    // I want to access the inner class B' members in Class C.
    }


  2. #2
    Super Moderator
    Join Date
    Jun 2013
    Location
    So. Maryland, USA
    Posts
    5,520
    My Mood
    Mellow
    Thanks
    215
    Thanked 698 Times in 680 Posts

    Default Re: Java Inner Class Access

    Welcome to the Forum! Please read this topic to learn how to post your code correctly along with other useful info for newcomers.

    What did you try, and what happened?

  3. #3
    Member andbin's Avatar
    Join Date
    Dec 2013
    Location
    Italy
    Posts
    443
    Thanks
    4
    Thanked 122 Times in 114 Posts

    Default Re: Java Inner Class Access

    Quote Originally Posted by sanjay_d View Post
    package pack2;
    public class C{
    // I want to access the inner class B' members in Class C.
    }
    You can't, since inner class B is private. The class B is not "visible" outside class A.
    Andrea, www.andbin.netSCJP 5 (91%) – SCWCD 5 (94%)

    Useful links for Java beginnersMy new project Java Examples on Google Code

Similar Threads

  1. How to access an ArrayList of another class?
    By mflevie44 in forum What's Wrong With My Code?
    Replies: 3
    Last Post: October 22nd, 2013, 04:21 AM
  2. How to access derived class field values?
    By ehsansh in forum What's Wrong With My Code?
    Replies: 8
    Last Post: October 1st, 2013, 05:08 AM
  3. Access and set variable in parent class through child
    By java_newbie in forum What's Wrong With My Code?
    Replies: 4
    Last Post: January 19th, 2011, 11:44 PM
  4. Cannot access class attributes
    By Cyburg in forum What's Wrong With My Code?
    Replies: 1
    Last Post: August 29th, 2010, 07:30 AM
  5. problem with data access when a class call another class
    By ea09530 in forum What's Wrong With My Code?
    Replies: 1
    Last Post: April 4th, 2010, 05:20 PM

Tags for this Thread