Results 1 to 6 of 6

Thread: Problem with Inner classes

  1. #1
    Join Date
    Mar 2010
    Posts
    200

    Problem with Inner classes

    Hello,
    I exercise very easy to achieve, create two different classes, compile and test the program. Until the whole works, then I do one of two class an inner class of another and get the same result. That is what I have been trying to do, but I have no correct method and my every try is unsuccessfully compiled. So, any help on this will be appreciated.

  2. #2
    Join Date
    Dec 2009
    Posts
    213

    Re: Problem with Inner classes

    Hello,
    I think you can try the following
    Code:
    BasicArray a =new BasicArray();
    But I do not think that you can access the method of the inner class from the above line code, even I have a very less idea about it. If you come to now about the exact solution for this then please even let me know about the same.

  3. #3
    Join Date
    Nov 2009
    Posts
    343

    Re: Problem with Inner classes

    Hello,
    You must declare your class as static , this will be good for your code
    Here is the syntax for it
    Code:
    Public static class example {
    The class call for you from the main function is static, make an inner class to call a function from the static. I think from this you can get an general idea of how the inner classes are used and for what purpose.

  4. #4
    Join Date
    Nov 2009
    Posts
    330

    Re: Problem with Inner classes

    Hello,
    I think you can do this in your program.
    Code:
    A = fac new fac(thisArray[i]);
    If this is not helpful then you can post back with your exact need and the error you are getting so that we can help you out.

  5. #5
    Join Date
    Mar 2010
    Posts
    200

    Re: Problem with Inner classes

    Hello,
    Yes thank you, I had put the class static. I have difficulty in understanding the principle of static class. I think the problem is quite solved now, but the static keyword is really giving me a issue in understanding the things. If you can explain me the static keyword with an example then it would be great. Thanks in advance.

  6. #6
    Join Date
    Nov 2009
    Posts
    446

    Re: Problem with Inner classes

    Hello,
    Some information on the static keyword, here is a sample code
    Code:
    class mutl {
        . . .
       
        public static double mean(int[] x) {
            int s = 0;  // s of all the elements
            for (int i=0; i<x.length; i++) {
                s += x[i];
            }
            return ((double)s) / x.length;
        }//endmethod mean
        . . .
    }
    Hope this will help you.

Similar Threads

  1. What are an Autoloading Classes in PHP?
    By Flaco in forum Software Development
    Replies: 5
    Last Post: 06-03-2010, 06:49 AM
  2. Communication between two classes
    By ANSEL in forum Software Development
    Replies: 4
    Last Post: 04-12-2009, 06:43 PM
  3. Sealed Classes in C#
    By Reegan in forum Software Development
    Replies: 5
    Last Post: 27-11-2009, 09:16 AM
  4. C # using classes in C + +
    By klite in forum Software Development
    Replies: 3
    Last Post: 01-10-2009, 10:15 AM
  5. Classes in VB.NET
    By Samir_1 in forum Software Development
    Replies: 2
    Last Post: 10-04-2009, 12:07 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,713,919,057.88599 seconds with 17 queries