Method of slimming kakalkov alexey

Let’s say I have three classes A, B and C.

  • B extends A
  • C extends B

All have a public void foo() method defined.

Now from C’s foo() method I want to invoke A’s foo() method (NOT its parent B’s method but the super super class A’s method).

I tried super.super.foo();, but it’s invalid syntax. How can I achieve this?

You can’t even use reflection. Something like

Class superSuperClass = this.getClass().getSuperclass().getSuperclass(); superSuperClass.getMethod("foo").invoke(this); 

would lead to an InvocationTargetException, because even if you call the foo-Method on the superSuperClass, it will still use C.foo() when you specify “this” in invoke. This is a consequence from the fact that all Java methods are virtual methods.

It seems you need help from the B class (e.g. by defining a superFoo(){ super.foo(); } method).

That said, it looks like a design problem if you try something like this, so it would be helpful to give us some background: Why you need to do this?

You can’t – because it would break encapsulation.

You’re able to call your superclass’s method because it’s assumed that you know what breaks encapsulation in your own class, and avoid that… but you don’t know what rules your superclass is enforcing – so you can’t just bypass an implementation there.

answered Aug 11 ’10 at 7:26

You can’t do it in a simple manner.

This is what I think you can do:

Have a bool in your class B. Now you must call B’s foo from C like but before doing this set the bool to true. Now in B’s foo check if the bool is true then do not execute any steps in that and just call A’s foo.

Hope this helps.

To quote a previous answer “You can’t – because it would break encapsulation.” to which I would like to add that:

However there is a corner case where you can,namely if the method is static (public or protected). You can not overwrite the static method.

Having a public static method is trivial to prove that you can indeed do this.

For protected however, you need from inside one of your methods to perform a cast to any superclass in the inheritance path and that superclass method would be called.

This is the corner case I am exploring in my answer:

public class A {     static protected callMe(){         System.out.println("A");     } }  public class B extends A {     static protected callMe(){         System.out.println("B");     } }  public class C extends B {     static protected callMe(){         System.out.println("C");         C.callMe();     }      public void accessMyParents(){         A a = (A) this;         a.callMe(); //calling beyond super class     } } 

The answer remains still No, but just wanted to show a case where you can, although it probably wouldn’t make any sense and is just an exercise.

Yes you can do it. This is a hack. Try not to design your program like this.

class A {     public void method()     { /* Code specific to A */ } }  class B extends A {     @Override     public void method()     {         //compares if the calling object is of type C, if yes push the call to the A's method.        if(this.getClass().getName().compareTo("C")==0)        {             super.method();         }        else{  /*Code specific to B*/  }      } }  class C extends B {     @Override     public void method()     {          /* I want to use the code specific to A without using B */          super.method();      } } 

It’s not possible, we’re limited to call the superclass implementations only.

answered Aug 11 ’10 at 7:25

I smell something fishy here.

Are you sure you are not just pushing the envelope too far “just because you should be able to do it”? Are you sure this is the best design pattern you can get? Have you tried refactoring it?

answered Aug 11 ’10 at 8:41

I had a problem where a superclass would call an top class method that was overridden. This was my workaround…

//THIS WOULD FAIL CALLING SUPERCLASS METHODS AS a1() would invoke top class METHOD

class foo1{  public void a1(){   a2();   }  public void a2(){}  } class foo2 extends foo1{  {  public void a1(){ //some other stuff  super.a1();  }  public void a2(){ //some other stuff  super.a2();  } 

//THIS ENSURES THE RIGHT SUPERCLASS METHODS ARE CALLED //the public methods only call private methods so all public methods can be overridden without effecting the superclass’s functionality.

class foo1{  public void a1(){   a3();}  public void a2(){   a3();}  private void a3(){ //super class routine  } class foo2 extends foo1{  {  public void a1(){ //some other stuff  super.a1();  }  public void a2(){ //some other stuff  super.a2();  } 

I hope this helps. 🙂

answered Apr 16 ’13 at 16:07

Before using reflection API think about the cost of it.

It is simply easy to do. For instance:

C subclass of B and B subclass of A. Both of three have method methodName() for example.

public abstract class A {     public void methodName() {      System.out.println("Class A");    }  }   public class B extends A {     public void methodName() {       super.methodName();       System.out.println("Class B");    }     // Will call the super methodName    public void hackSuper() {       super.methodName();    }  }  public class C extends B {     public static void main(String[] args) {       A a = new C();       a.methodName();    }    @Override   public void methodName() {       /*super.methodName();*/       hackSuper();       System.out.println("Class C");   }  } 

Run class C Output will be: Class A Class C

Instead of output: Class A Class B Class C

Not the answer you’re looking for? Browse other questions tagged java inheritance override or ask your own question.

stackoverflow.com

This page provides information for learning the ZZ method. ZZ is a modern method for speed solving the Rubik’s Cube, originally proposed by Zbigniew Zborowski in 2006. Michal Hordecki’s ZZ Page provides a good background and description of the ZZ method for those who aren’t already familiar with it.

Interpretation of the algorithms presented here requires familiarity with standard cube notation.

If you’re new to ZZ, the stripped down beginner version shows only the topics required to get you started.

Contents

EOLine

This stage orients all edges on the cube (EO) while simultaneously placing the DF and DB edges (Line). This reduces the cube to the group, meaning the rest of the cube can be solved by turning only the L, R and U faces.

EOLine takes an average of ~6.127 moves and a maximum of 9 moves, but is without doubt the most difficult part of the ZZ method. For this reason, it is often divided into two sub-stages: (1) Edge orientation followed by (2) placement of the line edges. Also known as “EO+Line”.

Contents

  • Edge Orientation Detection
  • Edge Orientation Strategy
  • Edge Orientation Cases
  • Combining the EO and Line Phases
  • Optimising EOLine
  • Fingertricks and Looking Ahead Into F2L
  • Example EOLine Solves

F2L – The First Two Layers

This stage completes the first two layers by building two 1x2x3 blocks on either side of the Line made in the previous stage. Because all edges are now oriented it is possible to complete this stage using just R, U and L moves.

Contents

  • Basic Block Building Strategy
  • 1x2x2 Blocks
  • 1x1x2 Blocks
  • Algorithms for Special Cases
  • D-layer 1x1x2s
  • Corner Already Placed
  • Edge Already Placed
  • Connected Cubies
  • Badly Connected Blocks
  • Multiblocking
  • Openslotting
  • ZZF2L Lookahead / General Tips

LL – The Last Layer

Because edge orientation is solved during EOLine and preserved during F2L, the last layer edges will always be oriented. This provides great number of options, ranging from a simple 20 algorithm 2-look system, all the way up to a 1-look system with up to 493 algorithms to learn.

Contents

  • OCLL/PLL
  • COLL/EPLL
  • OCELL/CPLL
  • ZBLL
  • ZZLL
  • Winter Variation
  • ZZ-CT
  • MGLS
  • Blah’s Method

Example Solves

These YouTube links below show examples of ZZ in action:

  • 3x3x3 17.58s Lodz Open 2011 – by Zbigniew Zborowski
  • 8.13 OH single – by Phil Yu
  • 10.88 Official Average, 9.40 Single – by Eli Lifland
  • 11.90 ZZ2h 10 of 12 – by Phil Yu
  • 9.95s ZZ solve – by Sam Hanna
  • 3x3x3 Rubik’s Cube 15.06 average – by Mateusz Kurek
  • Two ZZ Solves – 14.37, 15.91 – by yurivish
  • 15.82 ZZ solve – by nnitay6669
  • 16.73 Avg of 12, with reconstructions – by Conrad Rider

Click here for some detailed ZZ walkthroughs…

References & Resources

  1. Zbigniew Zborowski’s polish ZZ page (applet warning!)
  2. Michal Hordecki’s ZZ Page
  3. speedsolving.com: ZZ/ZB Home Thread
  4. speedsolving.com: ZZ Speedcubing Method
  5. speedsolving.com: ZZ Cubers
  6. speedsolving.com wiki: ZZ Method
  7. speedsolving.com: New method?
  8. YouTube: ZZ method tutorial
  9. YouTube: EOLine tutorial
  10. Bernard Helmstetter’s Move Count Statistics
  11. Cube Explorer
  12. Lucas Garron’s Algorithm Animator
  13. ZZF2L Move Count Analysis (by Lars Vandenbergh)
  14. speedsolving.com: ZZF2L Move Count

List of Terms

  • bad edge A misoriented edge
  • D-Face The lower surface of the cube
  • D-Layer The lower 1x3x3 block of cubies
  • DB The down-back edge
  • DF The down-front edge
  • EO Edge Orientation
  • EO+Line Edge Orientation followed by Line placement
  • EOLine Edge Orientation and Line placement executed as a single step
  • F2L First Two Layers: The lower 2x3x3 block of the cube
  • HTM Half Turn Metric: Defines a quarter or half turn of any face as a single move
  • line edges The DF and DB edges. When placed they form a line on the D-face
  • LL Last Layer: The U-layer
  • mid-slice The middle horizontal layer of the cube, sandwiched between the U and D layers (also known as the E-slice)
  • ZZ Zbigniew Zborowski: A Polish speedcuber and original proposer of the ZZ method

cube.crider.co.uk

This article is about asymptotic stability of nonlinear systems. For stability of linear systems, see

exponential stability

.

Various types of stability may be discussed for the solutions of differential equations or difference equations describing dynamical systems. The most important type is that concerning the stability of solutions near to a point of equilibrium. This may be discussed by the theory of Lyapunov. In simple terms, if the solutions that start out near an equilibrium point xe{displaystyle x_{e}} stay near xe{displaystyle x_{e}} forever, then xe{displaystyle x_{e}} is Lyapunov stable. More strongly, if xe{displaystyle x_{e}} is Lyapunov stable and all solutions that start out near xe{displaystyle x_{e}} converge to xe{displaystyle x_{e}}, then xe{displaystyle x_{e}} is asymptotically stable. The notion of exponential stability guarantees a minimal rate of decay, i.e., an estimate of how quickly the solutions converge. The idea of Lyapunov stability can be extended to infinite-dimensional manifolds, where it is known as structural stability, which concerns the behavior of different but “nearby” solutions to differential equations. Input-to-state stability (ISS) applies Lyapunov notions to systems with inputs.

History

Lyapunov stability is named after Aleksandr Mikhailovich Lyapunov, a Russian mathematician who defended the thesis The General Problem of Stability of Motion at Moscow University in 1892. A. M. Lyapunov was a pioneer in successful endeavoring to develop the global approach to the analysis of the stability of nonlinear dynamical systems by comparison with the widely spread local method of linearizing them about points of equilibrium. His work, initially published in Russian and then translated to French, received little attention for many years. The mathematical theory of stability of motion, founded by A. M. Lyapunov, considerably anticipated the time for its implementation in science and technology. Moreover, he did not have doctoral students who followed the research in the field of stability and his own destiny was terribly tragic because of Russian revolution of 1917. For several decades the theory of stability sank into complete oblivion. The Russian-Soviet mathematician and mechanician Nikolay Gur’yevich Chetaev was first who realized the incredible magnitude of the discovery made by A. M. Lyapunov. Actually, his figure as a great scientist is comparable to the one of A. M. Lyapunov. The contribution to the theory made by N. G. Chetaev was so significant that many mathematicians, physicists and engineers consider him a Lyapunov’s direct successor and the next-in-line scientific descendant in the creation and development of the mathematical theory of stability.

The interest in it suddenly skyrocketed during the Cold War period when the so-called “Second Method of Lyapunov” (see below) was found to be applicable to the stability of aerospace guidance systems which typically contain strong nonlinearities not treatable by other methods. A large number of publications appeared then and since in the control and systems literature. More recently the concept of the Lyapunov exponent (related to Lyapunov’s First Method of discussing stability) has received wide interest in connection with chaos theory. Lyapunov stability methods have also been applied to finding equilibrium solutions in traffic assignment problems.

Definition for continuous-time systems

Consider an autonomous nonlinear dynamical system

x˙=f(x(t)),x(0)=x0{displaystyle {dot {x}}=f(x(t)),;;;;x(0)=x_{0}},

where x(t)∈D⊆Rn{displaystyle x(t)in {mathcal {D}}subseteq mathbb {R} ^{n}} denotes the system state vector, D{displaystyle {mathcal {D}}} an open set containing the origin, and f:D→Rn{displaystyle f:{mathcal {D}}rightarrow mathbb {R} ^{n}} continuous on D{displaystyle {mathcal {D}}}. Suppose f{displaystyle f} has an equilibrium at xe{displaystyle x_{e}} so that f(xe)=0{displaystyle f(x_{e})=0} then

  1. This equilibrium is said to be Lyapunov stable, if, for every ϵ>0{displaystyle epsilon >0}, there exists a δ>0{displaystyle delta >0} such that, if ‖x(0)−xe‖ such that if ‖x(0)−xe‖α>0,β>0,δ>0{displaystyle alpha >0,beta >0,delta >0} such that if ‖x(0)−xe‖
    en.wikipedia.org

    This article is about asymptotic stability of nonlinear systems. For stability of linear systems, see

    exponential stability

    .

    Various types of stability may be discussed for the solutions of differential equations or difference equations describing dynamical systems. The most important type is that concerning the stability of solutions near to a point of equilibrium. This may be discussed by the theory of Lyapunov. In simple terms, if the solutions that start out near an equilibrium point xe{displaystyle x_{e}} stay near xe{displaystyle x_{e}} forever, then xe{displaystyle x_{e}} is Lyapunov stable. More strongly, if xe{displaystyle x_{e}} is Lyapunov stable and all solutions that start out near xe{displaystyle x_{e}} converge to xe{displaystyle x_{e}}, then xe{displaystyle x_{e}} is asymptotically stable. The notion of exponential stability guarantees a minimal rate of decay, i.e., an estimate of how quickly the solutions converge. The idea of Lyapunov stability can be extended to infinite-dimensional manifolds, where it is known as structural stability, which concerns the behavior of different but “nearby” solutions to differential equations. Input-to-state stability (ISS) applies Lyapunov notions to systems with inputs.

    History

    Lyapunov stability is named after Aleksandr Mikhailovich Lyapunov, a Russian mathematician who defended the thesis The General Problem of Stability of Motion at Moscow University in 1892. A. M. Lyapunov was a pioneer in successful endeavoring to develop the global approach to the analysis of the stability of nonlinear dynamical systems by comparison with the widely spread local method of linearizing them about points of equilibrium. His work, initially published in Russian and then translated to French, received little attention for many years. The mathematical theory of stability of motion, founded by A. M. Lyapunov, considerably anticipated the time for its implementation in science and technology. Moreover, he did not have doctoral students who followed the research in the field of stability and his own destiny was terribly tragic because of Russian revolution of 1917. For several decades the theory of stability sank into complete oblivion. The Russian-Soviet mathematician and mechanician Nikolay Gur’yevich Chetaev was first who realized the incredible magnitude of the discovery made by A. M. Lyapunov. Actually, his figure as a great scientist is comparable to the one of A. M. Lyapunov. The contribution to the theory made by N. G. Chetaev was so significant that many mathematicians, physicists and engineers consider him a Lyapunov’s direct successor and the next-in-line scientific descendant in the creation and development of the mathematical theory of stability.

    The interest in it suddenly skyrocketed during the Cold War period when the so-called “Second Method of Lyapunov” (see below) was found to be applicable to the stability of aerospace guidance systems which typically contain strong nonlinearities not treatable by other methods. A large number of publications appeared then and since in the control and systems literature. More recently the concept of the Lyapunov exponent (related to Lyapunov’s First Method of discussing stability) has received wide interest in connection with chaos theory. Lyapunov stability methods have also been applied to finding equilibrium solutions in traffic assignment problems.

    Definition for continuous-time systems

    Consider an autonomous nonlinear dynamical system

    x˙=f(x(t)),x(0)=x0{displaystyle {dot {x}}=f(x(t)),;;;;x(0)=x_{0}},

    where x(t)∈D⊆Rn{displaystyle x(t)in {mathcal {D}}subseteq mathbb {R} ^{n}} denotes the system state vector, D{displaystyle {mathcal {D}}} an open set containing the origin, and f:D→Rn{displaystyle f:{mathcal {D}}rightarrow mathbb {R} ^{n}} continuous on D{displaystyle {mathcal {D}}}. Suppose f{displaystyle f} has an equilibrium at xe{displaystyle x_{e}} so that f(xe)=0{displaystyle f(x_{e})=0} then

    1. This equilibrium is said to be Lyapunov stable, if, for every ϵ>0{displaystyle epsilon >0}, there exists a δ>0{displaystyle delta >0} such that, if ‖x(0)−xe‖ such that if ‖x(0)−xe‖α>0,β>0,δ>0{displaystyle alpha >0,beta >0,delta >0} such that if ‖x(0)−xe‖
      en.wikipedia.org

Leave a Reply

Your email address will not be published. Required fields are marked *