This and super keywords, array.length attribute

'this' and 'super' keywords and array.length attribute are declared in which java class?
and also during running of a java program how they are initialized and how they work?

'this' and 'super' keywords and array.length attribute are declared in which java class?They are not declared in any Java class, any more than the keywords 'class', 'interface', 'for', 'while', etc., are. They are defined in the grammar of the Java language, in the Java Language Specification.
and also during running of a java program how they are initialized and how they work?That's much too large a question for a forum. Try reading the Java Tutorial.

Similar Messages

  • This and super keyword

    what is the difference between this and super keyword?

    this serves as a reference to the current object whilst super refers to the superclass of the current object.

  • This() and super() invocations in constructor bodies

    Hi,
    Could someone please explain why it is not allowed to explicitly
    call this() or super() in a constructor body anywhere as opposed
    to the first statement in the constructor (which in turn implies that
    this() and super() can not be used together) ?
    Also, If the constructor is a constructor for an enum type, it is a compile-time
    error for it to invoke the superclass constructor explicitly. Why ?
    And the last question - why it is not allowed to invoke this() or super()
    with instance fields ?
    Cheers,
    Adrian

    AdrianSosialik wrote:
    Could someone please explain why it is not allowed to explicitly
    call this() or super() in a constructor body anywhere as opposed
    to the first statement in the constructorI think it was a language design decision. One could allow certain statements before invoking another constructor, but this would probably cause more confusion than help. So I guess it was deliberatly chosen to not allow this.
    (which in turn implies that this() and super() can not be used
    together) ?Yes, but if this would be permitted, it would also be harder to guarantee that a superclass constructor gets called exactly once.
    Also, If the constructor is a constructor for an enum type,
    it is a compile-time error for it to invoke the superclass
    constructor explicitly. Why ?Could you provide a "compilable" code snippet that demonstrates this?
    And the last question - why it is not allowed to invoke this()
    or super() with instance fields ?As you are not able to store something in them before the invocation, they contain their default values... (the JVM allows storing values in instance fields before invoking another constructor, but it was apparently decided to not include such a thing in Java)

  • What's the difference between this and super in this class

    public interface Doggie {
    public void wao();
    public void fetchBall();
    public void run();
    public void sleep();
    public class Kittie {
    public void miao() {
    public void catchRat() {}
    public void run() {}
    public void sleep() {}
    public class KtoD extends Kittie implements Doggie {
    public void wao() {
    this.miao();//here super.miao() will work too,
    //what is the difference between them?
    public void fetchBall() {
    this.catchRat();//here too
    public void run() {
    super.run();
    public void sleep() {
    super.sleep();
    }

    well, just off the top of my head (someone who wants to quote the relevant parts of the JLS can reply here too) - this makes sense, because your KtoD class extends Kittie, which has a miao method. You've not overridden this method, so KtoD's miao method is Kittie's method. Thus, this.miao() and super.miao() refer to the same method. If you had overridden this method in your KtoD class then this.miao() would refer to the overridden miao method, and if you had wanted to call the miao method from Kittie then you would have had to use super.miao()
    Did that answer your question?
    Lee

  • This and super?

    anybody knows why when I used "this" to call a subclass in a subclass and used "super" to call a subclass in a subclass the output is the same
    Is there any difference with that 2? thanks..

    CodeSniffer wrote:
    The "super" calls the method in the first class , it ignores the same name in other subclasses, it just calls the first method declared in the first class
    and the "this" calls the method just within the class
    am i right?Is that description consistent with the output from this program?
    class A {
        public void f() {System.out.println("A.f");}
        public void g() {System.out.println("A.g");}
        public void h() {System.out.println("A.h");}
    public class B extends A {
        @Override public void g() {System.out.println("B.g");}
        public void example() {
            super.f();
            this.f();
            super.g();
            this.g();
            super.h();
            this.h();
        public static void main(String[] args) {
            new C().example();
    class C extends B {
        @Override public void h() {System.out.println("C.h");}
    }

  • Keywords "this" and "super"

    Hi,
    For the readability of my codes, I use the keyword "super" instead of "this" or nothing in a class to refer to the metheod defined in its super class, even if there is no overwritting of that method.
    Is there any risk of this practice?
    Your comments are welcome.
    Cheers,
    Pengyou

    I was not convinced by the first two ...You should have your keyboard taken away. :pclass RealizationOfSomething {
    protected void doSomething() {
    // implementation here
    // implementation here
    // implementation here
    // implementation here
    // implementation here
    // implementation here
    // implementation here
    class MyClass extends RealizationOfSomething {
    public void doSomethingElse() {
    //first do many other things .....
    //then doSomething as
    super.doSomething(); // 1
    this.doSomething(); // 2
    doSomething(); // 3
    A: if MyClass overrides doSomething, then 1 is different from 2
    B: if MyClass does not override doSomething, then is 1 the same as 2 (performance)?
    If yes, then for the reason of "readability", I prefer 1; for the reason of maintenance, I accept 2.
    In any case, I would ignore the lazy case 3, although most people use it.
    This is my conclusion.
    Pengyou

  • This and super funda

    what is the difference b/w the statements
    super(title);and
    this.title=title;in the definition of a constructor for a class
    sam

    sorry was feeling sleepy so asked such a ques.
    thanx neway
    samThen wake up my dear!
    These things are fun and they're right at the heart of OOPs - so they have to be understood and <emphasis>PLAYED WITH</emphasis>, this is the only real way to understand - So be awake and play, it was written just for you;-class SuperClass{
       String str = "Hello my baby subclass.";
       public SuperClass(){
          System.out.println("I'm right right here");
       public SuperClass(String str){
          System.out.println(this.str);
    public class Subclass extends SuperClass{
       static String str="Hi dad, where's super constructor?";
       public static void main(String []params){
          new Subclass("");
       Subclass(String str){
          super(str);
          System.out.println(this.str);
          new SuperClass();

  • This ans super

    < Why the "this" and "super" objects of java are non-=static? >

    JoachimSauer wrote:
    What would a static "this" refer to?A static this (you'd have to call it something else, say thisClass) would be treated as an alias for the class name of the enclosing class. You could use it in situations like:
    private static ImageIcon = new ImageIcon(thisClass.class.getResource("img.png"));Or
    private static Log log = LogFactory.getLog(thisClass.class);

  • How to set array length correctly in this case

      class RunJavaCode implements ActionListener{
        public void actionPerformed(ActionEvent e){
          try{
            Process proc=Runtime.getRuntime().exec("java javaapp");
            InputStream input=proc.getInputStream();
            byte[] b=new byte[3000];
            input.read(b);              
            String javaReport=new String(b);
            input.close();
            outputText.setText(javaReport);
          }catch(IOException ioex){System.out.println("IOException is "+ioex);}
      }how to set this array(byte[] b) length correctly? I mean this array length should not only save memory,but also enough to use('enough to use' mean that read outputed info from console to this byte array never overflow)

    Hi,
    you cannot know in advance, how many bytes will be read. But the read-method returns the number of bytes actually read and this is important!
    So at least you have to write:        int r = input.read(b);
            String javaReport=new String(b, 0, r); However, you still do not know, whether there is even more output available. You could however retrieve the data in a loop and append it e.g. to a StringBuffer, until EOF is encountered.

  • I am having problems copying and pasting clips from one project timeline to another. When I do this they often alter in length. Sometimes by two frames. Other times they lose a chunk off the end of the last clip in the sequence. Has anyone else found

    I am having problems copying and pasting clips from one project timeline to another. When I do this they often alter in length. Sometimes by two frames. Other times they lose a chunk off the end of the last clip in the sequence. Has anyone else found this?

    You need to give a lot more information about the media specifications and the project properties you're using in the different projects.

  • I have a new mac book pro System Version: OS X 10.9.4 just one week old. When i play games using chrome the mac gets super hot and in the middle and the bottom. I had to return a mac last week because of this and got a new one replaced. But it still

    I have a new mac book pro System Version: OS X 10.9.4 just one week old. When i play games using chrome the mac gets super hot and in the middle and the bottom. I had to return a mac last week because of this and got a new one replaced. But it still

    I ran the diagnostics suggested in Macbook Pro Running Slow and Overheating, High kernel_task CPU Usage. Results below. Any help would be great.
    System Version: OS X 10.9.4 (13E28) 
    Kernel Version: Darwin 13.3.0
    Boot Mode: Normal
    Model: MacBookPro11,1
    USB
       Dell USB Optical Mouse (Dell Inc.)
    System diagnostics
       2014-09-20 PluginProcess spin
       2014-09-20 PluginProcess spin
       2014-09-20 iTunes spin
       2014-09-22 PluginProcess spin
       2014-09-22 PluginProcess spin
       2014-09-25 PluginProcess spin
       2014-09-26 Google Chrome spin
       2014-09-26 Google Chrome spin
    User diagnostics
       2014-09-20 CalendarAgent crash
       2014-09-22 DashboardClient crash
    Kernel messages
       Sep 26 17:21:23   IOPPF: Sent gpu-internal-plimit-notification last value 4 (rounded time weighted average 4)
       Sep 26 17:21:35   IOPPF: Sent cpu-plimit-notification last value 5 (rounded time weighted average 5)
       Sep 26 17:21:35   IOPPF: Sent gpu-internal-single-slice-plimit-notification last value 3 (rounded time weighted average 3)
       Sep 26 17:21:35   IOPPF: Sent gpu-internal-plimit-notification last value 3 (rounded time weighted average 3)
       Sep 26 17:21:47   IOPPF: Sent cpu-plimit-notification last value 8 (rounded time weighted average 7)
       Sep 26 17:21:47   IOPPF: Sent gpu-internal-single-slice-plimit-notification last value 3 (rounded time weighted average 3)
       Sep 26 17:21:47   IOPPF: Sent gpu-internal-plimit-notification last value 3 (rounded time weighted average 3)
       Sep 26 17:22:01   IOPPF: Sent cpu-plimit-notification last value 5 (rounded time weighted average 7)
       Sep 26 17:22:01   IOPPF: Sent gpu-internal-single-slice-plimit-notification last value 2 (rounded time weighted average 3)
       Sep 26 17:22:01   IOPPF: Sent gpu-internal-plimit-notification last value 2 (rounded time weighted average 3)
       Sep 26 17:22:21   IOPPF: Sent cpu-plimit-notification last value 10 (rounded time weighted average 9)
       Sep 26 17:22:21   IOPPF: Sent gpu-internal-single-slice-plimit-notification last value 4 (rounded time weighted average 3)
       Sep 26 17:22:21   IOPPF: Sent gpu-internal-plimit-notification last value 4 (rounded time weighted average 3)
       Sep 26 17:22:34   IOPPF: Sent cpu-plimit-notification last value 8 (rounded time weighted average 8)
       Sep 26 17:22:34   IOPPF: Sent gpu-internal-single-slice-plimit-notification last value 5 (rounded time weighted average 5)
       Sep 26 17:22:34   IOPPF: Sent gpu-internal-plimit-notification last value 5 (rounded time weighted average 5)
       Sep 26 17:22:47   IOPPF: Sent cpu-plimit-notification last value 6 (rounded time weighted average 6)
       Sep 26 17:22:47   IOPPF: Sent gpu-internal-single-slice-plimit-notification last value 5 (rounded time weighted average 5)
       Sep 26 17:22:47   IOPPF: Sent gpu-internal-plimit-notification last value 5 (rounded time weighted average 5)
       Sep 26 17:23:01   IOPPF: Sent cpu-plimit-notification last value 7 (rounded time weighted average 7)
       Sep 26 17:23:01   IOPPF: Sent gpu-internal-single-slice-plimit-notification last value 5 (rounded time weighted average 5)
       Sep 26 17:23:01   IOPPF: Sent gpu-internal-plimit-notification last value 5 (rounded time weighted average 5)
       Sep 26 17:23:12   IOPPF: Sent cpu-plimit-notification last value 6 (rounded time weighted average 6)
       Sep 26 17:23:12   IOPPF: Sent gpu-internal-single-slice-plimit-notification last value 5 (rounded time weighted average 5)
       Sep 26 17:23:12   IOPPF: Sent gpu-internal-plimit-notification last value 5 (rounded time weighted average 5)
    Extrinsic daemons
       com.adobe.fpsaud
    Extrinsic agents
       com.google.keystone.user.agent
    launchd items
       /Library/LaunchDaemons/com.adobe.fpsaud.plist
        (com.adobe.fpsaud)
       Library/LaunchAgents/com.apple.FolderActions.enabled.plist
        (com.apple.FolderActions.enabled)
       Library/LaunchAgents/com.apple.FolderActions.folders.plist
        (com.apple.FolderActions.folders)
       Library/LaunchAgents/com.google.keystone.agent.plist
        (com.google.keystone.user.agent)
    Startup items
       /Library/StartupItems/TuxeraNTFSUnmountHelper/TuxeraNTFSUnmountHelper
    Extrinsic loadable bundles
       /Library/Internet Plug-Ins/Flash Player.plugin
        (com.macromedia.Flash Player.plugin)
       /Library/PreferencePanes/Flash Player.prefPane
        (com.adobe.flashplayerpreferences)
       /Library/PreferencePanes/Tuxera NTFS.prefPane
        (com.tuxera.ntfs.mac.prefpane)
       Library/Address Book Plug-Ins/SkypeABDialer.bundle
        (com.skype.skypeabdialer)
       Library/Address Book Plug-Ins/SkypeABSMS.bundle
        (com.skype.skypeabsms)
    User login items
       iTunesHelper
       Google Chrome
    Restricted user files: 45
    Elapsed time (s): 75

  • I have to wipe my computer clean as I have a corrupted file some where,I was wondering if I will lose all my keywords if i do this and what should i do to pervert this

    I have to wipe my computer clean as I have a corrupted file some where, I was wondering if I will lose all my keywords if i do this and what should I do to pervert this.

    Keywords are stored in the catalog. Just be sure your catalog(s) is backed up as well as all you image files before reformatting the drive.

  • My phone gets super hot! What is making my phone of this and how do I stop it from getting hot?

    My phone gets super hot! What is making my phone of this and how do I stop it from getting hot?

    If the internal temperature gets too high, you will see the following.
    Has this occured?

  • I have a new mac book pro System Version: OS X 10.9.4 just one week old. When i play games using chrome the mac gets super hot and in the middle and the bottom. I had to return a mac last week because of this and got a new one replaced.

    i have a new mac book pro System Version: OS X 10.9.4 just one week old. When i play games using chrome the mac gets super hot and in the middle and the bottom. I had to return a mac last week because of this and got a new one replaced.The issue still remains

    I ran the diagnostics suggested in Macbook Pro Running Slow and Overheating, High kernel_task CPU Usage The results are below.
    System Version: OS X 10.9.4 (13E28) 
    Kernel Version: Darwin 13.3.0
    Boot Mode: Normal
    Model: MacBookPro11,1
    USB
       Dell USB Optical Mouse (Dell Inc.)
    System diagnostics
       2014-09-20 PluginProcess spin
       2014-09-20 PluginProcess spin
       2014-09-20 iTunes spin
       2014-09-22 PluginProcess spin
       2014-09-22 PluginProcess spin
       2014-09-25 PluginProcess spin
       2014-09-26 Google Chrome spin
       2014-09-26 Google Chrome spin
    User diagnostics
       2014-09-20 CalendarAgent crash
       2014-09-22 DashboardClient crash
    Kernel messages
       Sep 26 17:21:23   IOPPF: Sent gpu-internal-plimit-notification last value 4 (rounded time weighted average 4)
       Sep 26 17:21:35   IOPPF: Sent cpu-plimit-notification last value 5 (rounded time weighted average 5)
       Sep 26 17:21:35   IOPPF: Sent gpu-internal-single-slice-plimit-notification last value 3 (rounded time weighted average 3)
       Sep 26 17:21:35   IOPPF: Sent gpu-internal-plimit-notification last value 3 (rounded time weighted average 3)
       Sep 26 17:21:47   IOPPF: Sent cpu-plimit-notification last value 8 (rounded time weighted average 7)
       Sep 26 17:21:47   IOPPF: Sent gpu-internal-single-slice-plimit-notification last value 3 (rounded time weighted average 3)
       Sep 26 17:21:47   IOPPF: Sent gpu-internal-plimit-notification last value 3 (rounded time weighted average 3)
       Sep 26 17:22:01   IOPPF: Sent cpu-plimit-notification last value 5 (rounded time weighted average 7)
       Sep 26 17:22:01   IOPPF: Sent gpu-internal-single-slice-plimit-notification last value 2 (rounded time weighted average 3)
       Sep 26 17:22:01   IOPPF: Sent gpu-internal-plimit-notification last value 2 (rounded time weighted average 3)
       Sep 26 17:22:21   IOPPF: Sent cpu-plimit-notification last value 10 (rounded time weighted average 9)
       Sep 26 17:22:21   IOPPF: Sent gpu-internal-single-slice-plimit-notification last value 4 (rounded time weighted average 3)
       Sep 26 17:22:21   IOPPF: Sent gpu-internal-plimit-notification last value 4 (rounded time weighted average 3)
       Sep 26 17:22:34   IOPPF: Sent cpu-plimit-notification last value 8 (rounded time weighted average 8)
       Sep 26 17:22:34   IOPPF: Sent gpu-internal-single-slice-plimit-notification last value 5 (rounded time weighted average 5)
       Sep 26 17:22:34   IOPPF: Sent gpu-internal-plimit-notification last value 5 (rounded time weighted average 5)
       Sep 26 17:22:47   IOPPF: Sent cpu-plimit-notification last value 6 (rounded time weighted average 6)
       Sep 26 17:22:47   IOPPF: Sent gpu-internal-single-slice-plimit-notification last value 5 (rounded time weighted average 5)
       Sep 26 17:22:47   IOPPF: Sent gpu-internal-plimit-notification last value 5 (rounded time weighted average 5)
       Sep 26 17:23:01   IOPPF: Sent cpu-plimit-notification last value 7 (rounded time weighted average 7)
       Sep 26 17:23:01   IOPPF: Sent gpu-internal-single-slice-plimit-notification last value 5 (rounded time weighted average 5)
       Sep 26 17:23:01   IOPPF: Sent gpu-internal-plimit-notification last value 5 (rounded time weighted average 5)
       Sep 26 17:23:12   IOPPF: Sent cpu-plimit-notification last value 6 (rounded time weighted average 6)
       Sep 26 17:23:12   IOPPF: Sent gpu-internal-single-slice-plimit-notification last value 5 (rounded time weighted average 5)
       Sep 26 17:23:12   IOPPF: Sent gpu-internal-plimit-notification last value 5 (rounded time weighted average 5)
    Extrinsic daemons
       com.adobe.fpsaud
    Extrinsic agents
       com.google.keystone.user.agent
    launchd items
       /Library/LaunchDaemons/com.adobe.fpsaud.plist
        (com.adobe.fpsaud)
       Library/LaunchAgents/com.apple.FolderActions.enabled.plist
        (com.apple.FolderActions.enabled)
       Library/LaunchAgents/com.apple.FolderActions.folders.plist
        (com.apple.FolderActions.folders)
       Library/LaunchAgents/com.google.keystone.agent.plist
        (com.google.keystone.user.agent)
    Startup items
       /Library/StartupItems/TuxeraNTFSUnmountHelper/TuxeraNTFSUnmountHelper
    Extrinsic loadable bundles
       /Library/Internet Plug-Ins/Flash Player.plugin
        (com.macromedia.Flash Player.plugin)
       /Library/PreferencePanes/Flash Player.prefPane
        (com.adobe.flashplayerpreferences)
       /Library/PreferencePanes/Tuxera NTFS.prefPane
        (com.tuxera.ntfs.mac.prefpane)
       Library/Address Book Plug-Ins/SkypeABDialer.bundle
        (com.skype.skypeabdialer)
       Library/Address Book Plug-Ins/SkypeABSMS.bundle
        (com.skype.skypeabsms)
    User login items
       iTunesHelper
       Google Chrome
    Restricted user files: 45
    Elapsed time (s): 75

  • 'super' keyword problem....

    hi everyone,
    I had this starnge problem with super keyword,it gives me this compile error "Error(1042,11): method insertString(int, java.lang.String, javax.print.attribute.AttributeSet) not found in class javax.swing.text.PlainDocument"
    hope any one could help
    thanx
    Code:
    import javax.swing.text.AttributeSet;
    import javax.swing.text.BadLocationException;
    import javax.swing.text.PlainDocument;
    import javax.print.attribute.AttributeSet;
    class myDocPattern extends PlainDocument
      public void insertString(int offs, String str, AttributeSet a) throws BadLocationException
        String oldText = this.getText(0,this.getLength());
        if (str.length() > 2 || "0123456789.".indexOf(str) < 0 || (str.equals(".") && offs <= 0) ||
           (oldText.length() > 3 && (oldText+str).indexOf(".") <= 1) || (oldText+str).length() > 7)
          java.awt.Toolkit.getDefaultToolkit().beep();
          return;
        super.insertString(offs, str, a);
    }

    I had this starnge problem with super keyword,it gives me this
    compile error "Error(1042,11): method insertString(int, java.lang.String,
    javax.print.attribute.AttributeSet)
    not found in class javax.swing.text.PlainDocument"
    > super.insertString(offs, str, a);Repeating what the compiler already told you: the superclass PlainDocument
    doesn't have a method named 'insertString' with a
    javax.print.attribute.AttributeSet type parameter; the last parameter type
    needs to be a javax.swing.text.AttributeSet. (identical class names in
    different packages).
    kind regards,
    Jos

Maybe you are looking for