What does static keyword do to a inner class?

What effect does the keyword static mean to a private class like as follows:
public class a
    private static class b
}

it means that class b does not have a reference to a containing a object
if you make class b public, you can then instantiate it outside of a

Similar Messages

  • Does anyone know what does the keyword section do?

    Does anyone know what does the keyword section do? Under "Any of the webpages -> Properties -> Basic tab -> Tags/Keywords"?
    Is it used for part of the google search?

    Its tagging (Classification), one of the bright feature of any content management system. It allows author to classify the content in system. There are various advantages but i would refer you to go through http://dev.day.com/docs/en/cq/current/wcm/tag_admin.html. Apart from that you can search in google as well to find relative information about classification in content management system.

  • What Does + After Keyword Tag Mean?

    I'm just starting to figure out keywording (LR 1.1, Win XP).  I created a Keyword 'Dogs' and as Children of Dogs <g> created Keywords for the individual dogs by name.  Just one of the dog names has a + sign after it.  What does this mean?<br /><br />Thanks.

    The keyword with the + on it is actually called "keyword shortcut" and
    can also be selected using the context menu of a certain tag. It's used
    for assigning that tag to photos using either the spay tool or the
    context menu.

  • What does static synchronized do ?

    Hi,
    I just heard someone talking about this.
    I never really have used static synchronized block of code.
    Any ideas on what it could be useful ?
    I am thinking it will make the instance of the class synchronized irrespective of how it is called... or may be just synchronizing a static method. Which one could be correct rather.. what is correct?
    Rgds

    Boom. Thanks for the answer. Just like a static class, method, block.
    I would probably then specify something like static synchronized., if I wanted em to be synchronised. All of them can be synchronized.. should have thought about it.
    thanks again

  • What does the keyword "native" mean?

    Thanks for tell me the use of the keyword "native"?

    JNI, or Java Native Interface, you can create a native libary (.dll for windows or .so for Unix-a-likes) to implement that methord.

  • What does the trim() method of the String class do in special cases?

    Looking here ( String (Java Platform SE 7 ) ), I understand that the trim() method of the String class "returns a copy of the string, with leading and trailing whitespace omitted", but I don't understand what the last special case involving Unicode characters is exactly.
    Looking here ( List of Unicode characters - Wikipedia, the free encyclopedia ), I see that U+0020 is a space character, and I also see the characters that follow the space character (such as the exclamation mark character).
    So, I decided to write a small code sample to try and replicate the behaviour that I quoted (from the API documentation of the trim method) in the multi-line comment of this same code sample. Here is the code sample.:
    public class TrimTester {
        public static void main(String[] args) {
             * "Otherwise, let k be the index of the first character in the string whose code
             * is greater than '\u0020', and let m be the index of the last character in the
             * string whose code is greater than '\u0020'. A new String object is created,
             * representing the substring of this string that begins with the character at
             * index k and ends with the character at index m-that is, the result of
             * this.substring(k, m+1)."
            String str = "aa!Hello$bb";
            System.out.println(str.trim());
    However, what is printed is "aa!Hello$bb" (without the quotes) instead of "!Hello$" (without the quotes).
    Any input to help me better understand what is going on would be greatly appreciated!

    That's not what I was thinking; I was thinking about the special case where the are characters in the String whose Unicode codes are greater than \u0020.
    In other words, I was trying to trigger what the following quote talks about.:
    Otherwise, let k be the index of the first character in the string whose code is greater than '\u0020', and let m be the index of the last character in the string whose code is greater than '\u0020'. A new String object is created, representing the substring of this string that begins with the character at index k and ends with the character at index m-that is, the result of this.substring(k, m+1).
    Basically, shouldn't the String returned be the String that is returned by the String class' substring(3,9+1) method (because the '!' and '$' characters have a Unicode code greater than \u0020)?
    It seems to not be the case, but why?

  • Dumb Question - what exactly does "Static" mean

    What exactly does static variables and methods? What are they for?
    I know "final" means once you set it that's it..but what does static mean?

    There is also a static block use for initialising static variables.
    If you look in c:\j2sdk1.4.???\src.zip you will find the source to the libraries.
    from com/sun/image/codec/jpeg/JPEGTable
    public class JPEGQTable {
         /** The number of coefficients in a DCT block */
         private static final byte QTABLESIZE = 64;
          * This is the sample luminance quantization table given in the
          * JPEG spec section K.1, expressed in zigzag order. The spec says
          * that the values given produce "good" quality, and when divided
          * by 2, "very good" quality.
         public static final JPEGQTable StdLuminance = new JPEGQTable();
         static {
              int [] lumVals = {
                   16,   11,  12,  14,  12,  10,  16,  14,
                   13,   14,  18,  17,  16,  19,  24,  40,
                   26,   24,  22,  22,  24,  49,  35,  37,
                   29,   40,  58,  51,  61,  60,  57,  51,
                   56,   55,  64,  72,  92,  78,  64,  68,
                   87,   69,  55,  56,  80, 109,  81,  87,
                   95,   98, 103, 104, 103,  62,  77, 113,
                   121, 112, 100, 120,  92, 101, 103,  99
              StdLuminance.quantval = lumVals;
         }

  • Your Opinions: Inner Classes Need static Members

    Hi All,
    I want to solicit opinions for a minor change to the way inner classes work. I submitted this as an RFE to Sun and they rejected it, really without giving a reason. I'd like to know your opinions. If there is strong support I will repost the RFE.
    As you probably know, inner classes cannot have static members. The following generates a compiler error:import java.util.*;
    public class MyClass {
       class MyInnerClass {
          // Next line causes compiler error...
          static Map m = new HashMap();
    }In order to get around this you have to make the Map variable a static member of the containing class:import java.util.*;
    public class MyClass {
       static Map m = new HashMap(); // so much for encapsulation...
       class MyInnerClass {
    }I am suggesting that inner class be allowed to contain static members. Here's my reasoning...please comment:
    There are times when members (i.e., fields and methods) rightfully belong to the class as a whole, not to any particular instance of a class. I'm sure we've all found times when it was necessary to have static members in our classes. The same issues that necessitated using static members in top-level classes make them desirable for inner classes as well.
    Designing a class as an inner class is a step toward encapsulation. By forcing static members that logically belong in an inner class to be declared in the containing class is to crack the encapsulation, IMHO.
    Even though a containing class has access to all of an inner class' members (including private members) and vice versa, I think the notion of inner static members still is more OO-ish.
    What are your opinions? Would allowing inner classes to contain static members make Java more object oriented? I think it would.
    Technically, I don't think there's any reason this cannot work since the JVM has no notion of inner classes, per se.
    What do you think?

    an inner class is effectively a non static instance
    variable of its enclosing class. Instance member, but not a variable. it's a class, a type, not a variable.
    >
    I think the problem here is that making a field static
    means more than just that that field and its value are
    common to every instance of the class. It means that
    the value is valid without an instantiation of that
    class.
    Since the class itself must be instantiated (it is
    not static), What do you mean, excatly, by "_must_ be instantiated"? You are not ever "required" to instantiate anything unless you want to use it.
    you can't have static member data inside it. I don't see how this follows from the previous part of the statement.
    How would you reference the static member data of
    the inner class? You would have to specify an
    instance of the inner class, and since this breaks
    the meaning of static, you can't have static members
    in an inner class.How about outerObj.InnerClass.staticMember The syntax is well defined. The question at hand is, do we really want to allow this? The syntax to do this should only be an issue after that question has been answered in the affirmative. The people at Sun have decided not to allow it, so for now, syntax is a non-issue.
    >
    if you wanted a static member in an inner class you
    could put it in a super class of the inner class...Or in the enclosing class, as suggested in the orginal post.

  • What does MyClass.class.getClassLoader().getResource() do?

    Um. . .ok, I'm having a LD moment here. . .
    What does this java statement do?
    MyClass.class.getClassLoader().getResource("scripts").getPath() ;

    Here's the error from the log:
    java.lang.NullPointerException
         at com.oneok.dbLoader.scripts.OngDailyScriptLoader.getScripts(OngDailyScriptLoader.java:46)
         at com.oneok.dbLoader.scripts.OngDailyScriptLoader.Run(OngDailyScriptLoader.java:465)
         at com.oneok.dbLoader.scripts.OngDailyScriptLoader.run(OngDailyScriptLoader.java:494)
         at org.apache.jsp.runScript_jsp._jspService(runScript_jsp.java:52)
         at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:98)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
         at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:328)
         at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:315)
         at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
         at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:269)
         at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
         at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:210)
         at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:174)
         at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
         at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)
         at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:108)
         at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:151)
         at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:870)
         at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:665)
         at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:528)
         at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:81)
         at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:685)
         at java.lang.Thread.run(Unknown Source)

  • Inner classes use

    what is the main goal behind using inner classes in java design

    The best thing about inner classes in Java (something they missed in the C++ spec) is that a non-static inner class has direct access to everything in the containing class without the need to maintain an explicit reference.
    That makes inner class instances ideal as a kind of "delegate" from the main object into another context, e.g. to generate several ActionListener objects to be added to various gadgets, or as an Iterator which moves through some child elements.

  • Why do we go for inner classes in java?

    why cant we inherit the classes instead of having inner classes.
    what is the exact difference between the inner class and subclass.
    can anyone please explain me with some examples

    An inner class doesn't have any relationship with the outer class per se,
    except for one thing: an instantiation of the inner class can refer to the
    members of the instantiation of the outer class. One instantiation of the
    outer class can have many instantiations of the inner class 'circling
    around' it. Try to implement the following example using inheritance:public class Star {
         private String name;
         public Star(String name) { this.name= name; }
         public Planet addPlanet(String name) { return new Planet(name); }
         public class Planet {
              private String name;
              private Planet(String name) { this.name= name; }
              public Moon addMoon(String name) { return new Moon(name); }
              public class Moon {
                   private String name;
                   private Moon(String name) { this.name= name; }
                   public String toString() { return name+" (circling around "+Planet.this+")"; }
              public String toString() { return name+" (circling around "+Star.this+")"; }
         public String toString() { return name; }
         public static void main(String[] args) {
              System.out.println(new Star("sun").addPlanet("earth").addMoon("moon"));
    }kind regards,
    Jos

  • Java inner classes

    G'day
    How does one - in CF - refer to an inner class (ClassFoo.Bar)
    of a given
    class (ClassFoo), when the constructor of ClassFoo takes an
    argument of
    type ClassFoo.Bar?
    For example the first, third,fourth and fifth constructors
    shown here:
    http://tinyurl.com/hfg9s
    (org.apache.lucene.document.Field).
    Any ideas?
    Adam

    >is the reason you can't use another "." because it is not
    a property of Field
    Thats my understanding, yes.
    > what does the $ represent
    Its part of the class name. It has to do with how java
    compiles the classes. It creates one file for the outer class and
    one for the inner class. The naming convention for inner class
    files is usually "OuterClassName$InnerClassName.class". So the
    class name passed to createObject() becomes
    bar = createObject("java", "OuterClassName$InnerClassName");

  • Anonymous Inner Class question

    How can I get "foof" to be echoed to the screen?
    class MyClass {
       void go() {
          Bar b = new Bar();
          b.doStuff(new Foo() {
             public void foof() {
                System.out.println("foof");
    interface Foo {
       void foof();
    class Bar {
       void doStuff(Foo f) {}
    public class TestWonder {
       public static void main (String... args) {
       new MyClass().go();
       //Why doesn't this print out "foof" to the screen? Nothing is echoed to the screen.
    }

    Sorry to be so thick, but I thought that the code did that already. Apparently it doesn't. In other words, how would the code invoke the override foof()? I should be clearer:
    I know if I change Bar's doStuff() to
    void doStuff(Foo f) {
    System.out.println("bar's dostuff");
    }then when go() is executed bar's dostuff will print out. But, what about the override in the anonymous inner class?
    Edited by: RonNYC2 on Feb 5, 2010 1:03 PM
    Edited by: RonNYC2 on Feb 5, 2010 1:05 PM

  • Crazy inner class question

    Write a java file and compile it. The compiled class size is X. Add an inner class and the size increases as well as adding another class file.
    Decompile both.
    You will see that the entire inner class is defined in the outer class as well as being in it's own class. Why is this necessary? Since you reference an inner class by using the outer class name, why do you need to have a separate inner class.class file generated?
    Thanks
    ST

    You will see that the entire inner class is defined in
    the outer class as well as being in it's own class.No, that is not true. The inner class is defined only in a separate class file.
    Why is this necessary? Since you reference an inner
    class by using the outer class name, why do you need
    to have a separate inner class.class file generated?Because inner classes was an addition to the Java language that the JVM does not know about. Therefore inner classes are translated into ordinary classes by the compiler.

  • What does keyword "final" mean?

    what does keyword "final" mean? and where can I find information about basic of Java?

    Another word about final-
    methods declared "final" cannot be overrided. For example:
    class Person {
         String name;
         double pay;
         /* these methods are static, meaning you can access them
         *  without making an object of this class. They're
         *  also delcared final, meaning the values will never change. */
         public static final int JANITOR = 1;
         public static final int PLUMBER = 2;
         public static final int PROGRAMMER = 3;
         public Person(String s) {
              name = s;
         public final void setJob(int job) {
              if (job == JANITOR) pay = 100.00;
              if (job == PLUMBER) pay = 300.00;
              if (job == PROGRAMMER) pay = 500.00;
              else pay = 00.00;
    }Now with that class, you can still use the final method setJob:
    Person myPerson = new Person("Bob");
    myPerson.setJob(Person.PROGRAMMER);But if you make an extension of Person, you can't ovverride the setJob method.
    (I'm not 100% sure that's the entire truth, but I'm pretty sure it is)

Maybe you are looking for

  • Error when dynamically creating and binding view object

    Hi, I'm using JDeveloper 10.1.2.1.0 (1913) to create a JSP - Struts - ADF BC application. I'm trying to create a lov page that is based on a viewobject whose query (and bindings) are set at runtime (like Steve Muench shows in one of his undocumented

  • CF 10 sp 12 Enterprise  high CPU usage hangs services, 2012 server on 2012 Hyper-V host

    The last 2 days - my [removed link] CF site has suffered from high CPU usage (on and off) that stops functionality. This will last several minutes then suddenly the high usage stops a few minute later the high cpu usage starts again. I don't have any

  • How to retain ownership (as an organization) of VPP apps

    Good morning, I am the mobile device/apple technology for a district school board. I'm having a real hard time pushing apps purchased through VPP to the schools and students in my district. The school board requires to retain ownership of the apps, a

  • Cannot type certain characters

    I have a brand new Ipod touch - right out of the box it appears to be defective - I cannot type certain characters, such as "C", and "T". Most characters do work but I believe the touch screen is dead in certain places. Is there any hope of this bein

  • I have problem with my Mail app. PLEASE HELP!

    When I initiated the "mail connection doctor" this statement appears: INITIATING CONNECTION Mar 25 17:52:55.189 [kCFStreamSocketSecurityLevelNone] -- host:imap.mail.yahoo.com -- port:993 -- socket:0x6080000db660 -- thread. Kindly please help me how t