4 Replies Latest reply: Dec 19, 2012 2:34 AM by TPD-Opitz RSS

    Static class

    978238
      i have two doubts

      1. how can i call static class as outer class?

      2.how to access variables from static class to non static class?

      Edited by: 975235 on Dec 18, 2012 9:36 PM
        • 1. Re: Static class
          EJP
          1. how can i call static class as super class?
          'static' doesn't make any difference to how you do that.
          2.how to access variables from static class to non static class?
          It doesn't make any difference to that either.
          • 2. Re: Static class
            978238
            give me some good suggeston


            package AssignmentStatic;
            //i like to assign String class like this..but its showng error wat can i do
            public static class s{
                 
                 int a=10;
                 
            }
            public class test1 {
                 
            public static void main(String a[])
            {
                 
            }
            }
            • 3. Re: Static class
              EJP
              975235 wrote:
              //i like to assign String class like this..
              public static class s{
              This is not an example of assigning the String class. Please explain.
              but its showng error
              What is showing what error?
              wat can i do
              You could start by asking a proper question. I doubt that if you got this question from a customer you would be able to make much sense of it. I can't.

              The only thing I can observe is that 'static' is illegal at the outermost scope, as it doesn't mean anything except inside another class. What exactly are you trying to accomplish?
              • 4. Re: Static class
                TPD-Opitz
                975235 wrote:
                i have two doubts
                Me too, and my doubt is: you are not aware of object oriented programming concepts. So you meight go though a OOP tutorial first:
                http://docs.oracle.com/javase/tutorial/java/concepts/
                1. how can i call static class as outer class?
                What do you mean by call ?
                In OOP you create instances of a class. We name these instances <i>objects</i>. And you call methods on that objects or static methods on the calsses themselves.

                What you not do is "call a class".
                2.how to access variables from static class to non static class?
                In OOP this quiestion should not araise at all.
                Variables are property of an object/class an nothing outside the object/class should access them (directly).
                There are only a few exception were constants are the most "legal".

                bye
                TPD