This keyword problem , how refer to super super class?

Hello
I had many times a problem on specifying this keyword as an argument to a constructor
For example in this case
package Test;
public class Model {
    public Model() {
    public void connect(){
        new Thread(){
            public void run(){
                new TestClass( *this* ).start();
}bolded this will refer to Thread class and i want it to refer to Model class i mean to the class up one level.
Is there a way to do that?
Edited by: neolegionar on Nov 20, 2008 3:16 AM

Model.this

Similar Messages

  • How to inherit super class constructor in the sub class

    I have a class A and class B
    Class B extends Class A {
    // if i use super i can access the super classs variables and methods
    // But how to inherit super class constructor
    }

    You cannot inherit constructors. You need to define all the ones you need in the subclass. You can then call the corresponding superclass constructor. e.g
    public B() {
        super();
    public B(String name) {
        super(name);
    }

  • Problem with subclass and super class

    here is the things i wanted to do
    /*Write a method that takes the time as three integer arguments (hours, minutes and seconds),
    and returns the number of seconds since the last time it was twelve o'clock.
    Write a program that uses this method to calculate the amount of time in seconds between two times,
    assuming both are within one twelve hour cycle of a clock.
    here is a class to find the last time closes to 120'clock in sec.
    import java.io.*;
    public class Timer {
         int converter = 60;
         int secinTwelveHour = 43200;
         int converter2 = 12;
    public int timerTime (int hour, int min, int sec){
              int totalSec = 0;
              //Finding the time
              if (hour > 0 && hour <= 24 && min > 0 && min <=60 && sec > 0 && sec <= 60 && hour <= 11){
                   //find last 12 o'Clock
                   hour = converter2 + hour;
                   //change to sec time
                   totalSec = (hour * converter * converter) + (min * converter) + sec;
              }else{     
         if (hour > 0 && hour <= 24 && min > 0 && min <=60 && sec > 0 && sec <= 60 && hour >= 12){
                   //find last 12 o'Clock in sec
                   totalSec = ((hour * converter * converter) + (min * converter) + sec) - secinTwelveHour;
         }else{
              return -1;
    }//End of return -1      
              }//End of first else statment
         return totalSec;     
         }//End of timerTimer
    }//End of Program     
    and here is the super class which uses the class aboved
    import java.io.*;
    public class FindTime {
    public int find2Time (int totalSec1, int totalSec2){
              int timeSec = 0;
              if(Timer.totalSec1 > Timer.totalSec2)
              timeSec = Timer.totalSec1 - Timer.totalSec2;
              else
              timeSec = Timer.totalSec2 - Timer.totalSec1;
         return timeSec;     
         }//End of find2Time
    public static void main( String [] arg){
         // Construct an instance of the Timer class
              Timer timerClass = new Timer();
              // Make a couple of calls of the method
              int totalSec1 = timerClass.timerTime(12, 3, 45);
              int totalSec2 = timerClass.timerTime(14, 23, 60);
              timeSec1 = find2Time (totalSec1, totalSec2)
              // Now print the values we got back
              System.out.println("Last closes Sec to 12 o'clock" + totalSec1);
              System.out.println("Last closes sec to 12 o'clock" + totalSec2);
              System.out.println("Last closes sec to 12 o'clock" + timeSec);
         }//End of main method
    }//End of Program     
    Now i'm having program with the compliing can anyone help me out like tell me what i'm doing wrong and give me a bit of a code so that i can have a push start
    thanks you

    Does this do what you want? It is in two seperate classes.
    import java.io.*;
    public class FindTime {
    public static void main( String [] arg){
    int timeSec = 0;
    // Construct an instance of the Timer class
         Timer timerClass = new Timer();
         // Make a couple of calls of the method
         int totalSec1 = timerClass.timerTime(12, 3, 45);
         int totalSec2 = timerClass.timerTime(14, 23, 60);
         timeSec = java.lang.Math.abs(totalSec1-totalSec2);
         // Now print the values we got back
         System.out.println("Last closes Sec to 12 o'clock " + totalSec1);
         System.out.println("Last closes sec to 12 o'clock " + totalSec2);
         System.out.println("Last closes sec to 12 o'clock " + timeSec);
         }//End of main method
    }//End of Program
    import java.io.*;
    public class Timer {
    int converter = 60;
    int secinTwelveHour = 43200;
    int converter2 = 12;
    public int timerTime (int hour, int min, int sec){
         int totalSec = 0;
         //Finding the time
         if (hour > 0 && hour <= 24 && min > 0 && min <=60 && sec > 0 && sec <= 60 && hour <= 11){
         //find last 12 o'Clock
         hour = converter2 + hour;
         //change to sec time
         totalSec = (hour * converter * converter) + (min * converter) + sec;
         } else {
         if (hour > 0 && hour <= 24 && min > 0 && min <=60 && sec > 0 && sec <= 60 && hour >= 12){
         //find last 12 o'Clock in sec
         totalSec = ((hour * converter * converter) + (min * converter) + sec) - secinTwelveHour;
         } else {
              return -1;
         }//End of return -1
    }//End of first else statment
    return totalSec;
    }//End of timerTimer
    }//End of Program

  • Keywords Following one of my top level keywords is a mid space dot. Every new keyword is inserted within this keyword. How to I get rid of this?  Chris

    I cannot add much to the above question, only say that I have three catalogues and the others do not share this issue.

    Do you mean:
    A) Get rid of the dot?
    or
    B) Get rid of the keyword entirely?

  • How to access super class's super class

    Hello every one.
    I have a question.
    if I have a class like:
    public class A {
    void methoda() {
    void methodb() {
    and a class B extends A and override A's methoda
    public class B extends A {
    void methoda() {
    and a class C extends B which want use A's methoda.
    public class C extends B {
    // and here I want to use class A 's methoda,how can I do?
    thanks a lot

    Try the following. When run it eill print out:
    [In class C] A:B:C
    Now calling A's method: [In class A] A and i is 500Which is what you want right?
    public class TestSuperSuper {
        public static void main (String[] args) throws Exception {
            C c = new C();
            c.setName("A", "B", "C");
            c.setI(500);
            c.methodA();
        static class A {
            String aName;
            int i;
            public void methodA(){
                System.out.println("[In class A] " + aName + " and i is " + i);
            public void setName(String aName){
                this.aName = aName;
            public void setI(int i){
                this.i = i;
        static class B extends A {
            String bName;
            public void methodA(){
                System.out.println("[In class B] " + aName + ":" + bName);
            public void setName(String aName, String bName){
                this.aName = aName;
                this.bName = bName;
        static class C extends B {
            String cName;
            A wrappedA;
            public C(){
                wrappedA = new A();
            public void methodA(){
                reflectOnA();
                System.out.println("[In class C] " + aName + ":" + bName + ":" + cName);
                System.out.print("Now calling A's method: ");
                wrappedA.methodA();
            public void setName(String aName, String bName, String cName){
                this.aName = aName;
                this.bName = bName;
                this.cName = cName;
            private void reflectOnA(){
                try {
                Field[] aFields = wrappedA.getClass().getDeclaredFields();
                for (int i = 0; i < aFields.length; i++){
                    Class fldType = aFields.getType();
    if (fldType.isPrimitive()){
    if (fldType.getName().equals("int")){
    aFields[i].setInt(wrappedA, aFields[i].getInt(this));
    else {
    // now do the other primitive type tests here
    else {
    aFields[i].set(wrappedA, aFields[i].get(this));
    catch (Exception e){
    System.err.println(e);
    The main thing here is that in class C you have an instance variable called wrappedA which is an instance of A and the method called reflectOnA(). Basically, what this method does is it will set all the fields in wrappedA to the same values that this object has so that it would look like that wrappedA is somewhat the same as this object. You will call this method whenever you want to call your superclass' superclass' method.
    Hope this helps.

  • Composition in java : how to access super-class from sub-class

    I have 3 classes related by composition
    class A{
    B b = new B();
    class B{
    List<C> cList = new ArrayList<C>();
    in class C{
    getSample(){
         //Try to access class A     
    how can I access A from class C ?
    Any help is appreciated!

    well, 'Id' is known only to class A, and class C has a getSample() which is called in class A.
    class A{
    B b = new B();
    getID(){
    return id;
    b.getC().getSample();
    class B{
    List<C> cList = new ArrayList<C>();
    class C{
    getSample(){
    if() {
    //pick up value from properties file
    // format the value and parameter substitute it with 'Id' from A
    The design does seem a little weird, but I guess this is the only way to do this considering the other constraints we have ....
    TIA

  • Jsut turned on my mac and the fan is blowing really hard is this a problem

    I just turned on my mac and the fan is blowing in over drive is this a problem how do i fix it

    Depends. We first need to know your iMAc model to know if your have a problem or a feautre. For a start, you can do "About this Mac" and tell us what it says about your Mac OSX version and processor type:

  • Using the 'this' keyword

    What is the use of the this keyword:
    import java.util.*;
    public abstract class LegalEntity implements HasAddress{
    private String address;
    private String area;
    private String registrationDate;
    private ArrayList accounts;
    public LegalEntity()
         accounts = new ArrayList();
    public void addAddress(String address){this.address = address;}
    public String getAddress(){return address;}
    public void addAccount(Account account)
         accounts.add(account);
    public ArrayList returnAccounts()
         return accounts;
    }

    This can be used when there are lots of static functions and you want to be sure you are invoking the current objects methods/members.

  • How do I reference a class in a .dll library?

    How do I reference a class in a .dll library?  The following code extracts the contents of a ListView after a line is MouseDoubleClick:
        static public void GetListViewValues(object sender, List<string> liststListViewValues)
          ListViewItem lvi = sender as ListViewItem;
          ListViewTabs obj = lvi.DataContext as ListViewTabs;
          liststListViewValues.Add(obj.tabNumber);
          liststListViewValues.Add(obj.tabDetails);
        public class ListViewTabs
          public string tabNumber { get; set; }
          public string tabDetails { get; set; }
    I want to move this code (not the class) into a library .dll.  The .dll is generic ... could be called by any namespace.  It needs to know about the ListViewTabs class in this example.
    bhs67

    >>How do I reference a class in a .dll library?
    You add a reference to the .dll (https://msdn.microsoft.com/en-us/library/wkze6zky.aspx?f=255&MSPPError=-2147217396) and add a using statement for the namespace
    in which the class is defined at the top of the code file in which you want to use the class:
    using YourNameSpace;
    >>I want to move this code (not the class) into a .dll.
    The method must be put into some class. You could create a class in the class library and put the method in there:
    namespace YourNameSpace
    public class YourClass
    static public void GetListViewValues(object sender, List<string> liststListViewValues)
    ListViewItem lvi = sender as ListViewItem;
    ListViewTabs obj = lvi.DataContext as ListViewTabs;
    liststListViewValues.Add(obj.tabNumber);
    liststListViewValues.Add(obj.tabDetails);
    public class ListViewTabs
    public string tabNumber { get; set; }
    public string tabDetails { get; set; }
    >>The .dll is generic ... could be called by any namespace.
    Every class belongs to a namespace (potentially the global (or unnamed) namespace) in C#.
    >>It needs to know about the ListViewTabs class in this example.
    If the method in the .dll needs to know about the ListViewTabs class you must put the ListViewTabs class into the same .dll or create another .dll, put the ListViewTabs class there and then add a reference to this .dll from the one containing your method.
    You cannot keep the ListViewTabs class in the WPF application project from which you add a reference to the .dll that contains the method because you cannot add a reference from A to B and from B to A as this will lead to a circular dependency.
    Hope that helps.
    Please remember to close your threads by marking helpful posts as answer and please start a new thread if you have a new question.

  • '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

  • Nor any of its super class is known to this context ...problem

    hi all
    i have simple complex object in jave that looks like this :
    @XmlAccessorType(XmlAccessType.FIELD)
    public class MyID{
        @XmlAttribute
        public short dbnum = (short)0;
        @XmlAttribute
        public short usernum= (short)0;
        @XmlAttribute
        public long userid = (long)0;
        public MyId(){
    }i converted it with jaxb and it generete me corespanding java object with the propreate geters and seters
    now when i try to in the server side to insert this object into List<Object> im geting error saing :
    Caused by: javax.xml.bind.JAXBException: com.WebServices.datastructures.MyID nor any of its super class is known to this context
    at com.sun.xml.bind.v2.runtime.JAXBContextImpl.getBeanInfo(JAXBContextImpl.java:474)
    at com.sun.xml.bind.v2.runtime.XMLSerializer.childAsXsiType(XMLSerializer.java:557)
    ... 47 more
    i must say that if i send back only this object (MyID) the unmarsheling passed successfully
    thanks for your help

    Ok I found it out
    jboss was using the jre default axis impelmentation while the server where my client was deployed was using the axis 2 implementation
    I changed the server to use jre default axis and things worked now
    Thanks
    Sapan

  • How to pass subclass to variable of super class ?

    class /EVUIT/EXCH_PRD_GUI definition
    public section.
      methods CONSTRUCTOR
        importing
          value(I_APPLICATION) type ref to /UIT/EXCH_PRD_APP optional
          value(I_REPID) like SY-REPID .
    class /UIT/EXCH_PRD_VERT_NN_MODEL definition
      public
      inheriting from /EVUIT/EXCH_PRD_APP
      create public .
    DATA: l_vert_nn_model type ref to /uit/exch_prd_vert_nn_model.
    DATA: l_gui type ref to /uit/exch_prd_gui_vbeleg.
       CREATE OBJECT l_vert_nn_model
            EXPORTING
              I_ALV_RECORDS = gt_alv_records[].
    CREATE OBJECT l_gui
       EXPORTING
         I_APPLICATION = l_vert_nn_model
         I_REPID = sy-repid .{color}
    Problem i am facing is for l_gui the parameter i_application is of type super class of l_vert_nn_model.
    Any suggestions, how can i pass this subclass object to the parameter which is of type super class?

    Hello Trivenn
    On SAP basis release 7.00 the following coding works:
    *& Report  ZUS_OO_DUMMY
    REPORT  zus_oo_dummy.
    *       CLASS lcl_local DEFINITION
    CLASS lcl_local DEFINITION.
      PUBLIC SECTION.
        METHODS:
          constructor
            IMPORTING
              value(io_instance)  TYPE REF TO zcl_edi_uk_svcs_out. " super class
      PRIVATE SECTION.
        data: mo_instance         type ref to object.
    ENDCLASS.                    "lcl_local DEFINITION
    *       CLASS lcl_local IMPLEMENTATION
    CLASS lcl_local IMPLEMENTATION.
      METHOD constructor.
        mo_instance ?= io_instance.
      ENDMETHOD.                    "constructor
    ENDCLASS.                    "lcl_local IMPLEMENTATION
    DATA: go_super    TYPE REF TO zcl_edi_uk_svcs_out,
          go_sub      TYPE REF TO zcl_edi_uk_svcs_out_customer,
          go_local    type ref to lcl_local.
    START-OF-SELECTION.
      CREATE OBJECT go_super.
      CREATE OBJECT go_sub.
      create object go_local
        exporting
          io_instance = go_sub.
      BREAK-POINT.
    END-OF-SELECTION.
    Regards
      Uwe

  • Javah problem - super class could not be found !!

    Hi all,
    i have already posted this message but i didn't get enough help to solve my poor situation.
    and this is my problem:
    i got in my project (myProject) MyClass class.
    i wrote in another java class ,in OtherClass.class ,jni function that use MyClass object as parameter to the jni interface, as follow:
    private native int myFunction (MyClass obj); //function in OtherClass
    when i write the javah command line :
    javah -jni OtherClass (in order to create OtherClass.h)
    i always get the following error:
    A required super class myPackage.MyClass could not be found.
    my qoustion is how can i let the javah command line to know about the existence of myPackage.MyClass and how can i create and .h file when i using other class instance as jni function parameter in other class??
    Thanks Sendy.

    Lets define a few terms here.
    Java can be a java virtual machine which is what runs when you type 'java' on the command line. It is also represented by the compiler which runs when you type 'javac'. And in your case it also is represented by 'javah'.
    The class path defines where java finds classes that it needs.
    In older versions of java you had to tell it where to find everything. It couldn't even find java.lang.String unless you told it were it was. Now days you have to tell it where to find stuff that you add (or where 3rd party libraries are.)
    There are two ways to define the class path: a command line option and an environment variable.
    A class path can, currently, have three types of things in it:
    -A path to a zip file
    -A path to a jar file
    -A path
    For example
    -Path to zip file in windows: C:\mystuff\mylib\mystuff.zip
    -Path to zip file in unix: /opt/system/projects/mystuff/mystuff.zip
    -Path to jar file in windows: C:\mystuff\mylib\myjar.jar
    -Path to jar file in unix: /opt/system/projects/mystuff/myjar.jar
    -Path in windows: C:\mystuff\mylib
    -Path in unix: /opt/system/projects/mystuff
    Zip files aren't used as much anymore, but you should at least be aware of them.
    Java uses the class path to look for classes which are stored in files. It does this by translating the class name into a file name. It uses packages as directory names and class names as file names. So in your case it would try to find a class called myPackage.MyClass in a file called myPackage\MyClass.class. It would try to find that in any zip files, jar files, in in any paths that you specified in the class path.
    So java is trying to find myPackage\MyClass.class in your class path. It would try to find that in any zip files, jar files, in in any paths that you specified in the class path.
    Right now your class path is probably just "." which means that if you do the following commands
    cd C:\mystuff
    javah -jni OtherClass
    Then java is going to try to find myPackage.MyClass in the following file
    .\myPackage\MyClass.class
    That, because you 'cd' to C:\mystuff, translates to the following absolute path
    C:\mystuff\myPackage\MyClass.class
    So if java doesn't find that file then it is going to tell you that it can't find the file.
    So where is your file? Let's say it is here.
    C:\work\lib\myPackage\MyClass.class
    So you must tell javah where the root is. Keep in mind that 'myPackage' must be part of the path. That is not optional. The root is the directory above 'myPackage'. So the root is
    C:\work\lib
    So now you have a path that is ready for your class path. So your javah command could look like this
    javah -classpath ".;C:\work\lib" -jni OtherClass
    Or using an environment variable
    set CLASSPATH=.;C:\work\lib
    javah -jni OtherClass
    Keep in mind in the above that class path is a generic term and there can be other ways to define it. For example the Sun command "java" allows you to use "-classpath" or "-cp".
    So does the above help?

  • How to indicate the object of the super Class ?

    hello,
    I need to notify when one dialog is close to the class that generated it.
    Of course I do it from the method windowClosing() in the class WindowAdapter.
    But if I use "this" how parameter in the method, I noted the value is that of the inner anonymous class, and not that of the dialog class.
    I write down some code to reproduce the problem ....
    public ReferenceToTheSuperClass() {
            final SecondClass sc = new SecondClass(this);
            jButton1 = new javax.swing.JButton();
    //        final ReferenceToTheSuperClass xx = this;
            jButton1.setText("jButton1");
            jButton1.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                     sc.checkSuper(xx);                    // work
                     sc.checkSuper(this);                   // not work
                     sc.checkSuper(super.getClass()); // not work
    }  // ReferenceToTheSuperClass
    class SecondClass {
        ReferenceToTheSuperClass superiorClass;
        public SecondClass(ReferenceToTheSuperClass supClass){
            superiorClass = supClass;
        public void checkSuper(Object o){
            if (o instanceof ReferenceToTheSuperClass){
                JOptionPane.showMessageDialog(null,"HELLO");
    } // SecondClass My ask is: It is possible to indicate the value of the instance of the super Class, inside one his anonynimous inner class?
    thank you
    regards
    tonyMrsangelo

    thank you for your kinkly answer jeverd,
    yes what you say is right, in this case the class is only nested (in the hurry I used a wrong word).
    About the sintax, I vould find only a short statement to use inside the inner anomymous class and, reading what you say, I can guess it is not possible to do it..
    again thank you
    regards
    tonyMrsangelo

  • How to get the subclass from a super class( or interface)

    hi,
    I want to get subclass from a super class (or a interface), how to do that? the subclass of a interface means the class implementing the interface.
    for example;
    List ls;
    I want to get the subclass of ls, i.e., LinkedList, Stack, Vector......
    AbstractList al;
    the subclass of al, i.e., ArrayList, Vector.......
    thanks
    Aiwu

    List ls = new ArrayList();Since ls has been declared as a List we can only use List methods
    with it. This is a good thing because we might later want to change
    it to some other sort of List.
    I want to get subclass from a super class (or a interface), how to do
    that?The instance of the subclass declared above did not really come
    from the super class. A class "knows nothing" about its
    subclasses: many sub classes would not even exist at the time
    the class was written.

Maybe you are looking for

  • ASA 5505 no internet

                       Dear all i have a problem with ASA 5505 i have three vlans : Inside, Guest, Outside the Inside's vlan network is 172.16.100.0  255.255.252.0 Guest                           is 192.168.1.0    255.255.252.0 Outside                   

  • Why is it no longer possible, since the iPhotos upgrade to 9, to select a number of photos and "hold on to them" when changing to a different left-margin "view"?

    There has been a downgrade since iPhotos was- upgraded. Before iPhotos was upgraded to 9, It USED to be that IF you chose a photo or a number of photos WITHIN an event (ensuring that they were engulfed in yellow or blue), and THEN went to the left ma

  • XML Thumbnail Photo gallery

    Hi, I'm almost done with this Photo Gallery project but I have one final issue with the photo gallery. I created a multidimensional array to group image paths from the XML file in sets of 9. When the array is called the images appear in the right ord

  • Mutliple serveres in a two node RAC

    hello friends m i newbie in RAC and i have 7 servers in my company 4 are for oracle database used for different purposes having same instance name on each of them and 3 are for application servers used for different purposes having same instance name

  • How to drop these

    i dropped some tables and after , when i issue, SELECT * FROM TAB; TNAME TABTYPE CLUSTERID BIN$9sbjQChwTxeA23XrZuL0Iw==$0 TABLE BIN$xSyv7VXhRa6t7sanNksS8A==$0 TABLE BIN$QRh6sniLS9eHmr9pkmwngQ==$0 TABLE BIN$x8YbWt9NRqyT9cRA29OYRA==$0 TABLE BIN$WeWb2jY