Generic BST that Extends Comparable, Method question.

private Node removeFromTreeHelper(     T value, Node curr )
    if( curr == null )               // If curr is null, then the
    {   ok = false;
        return null;               // VALUE is not in the tree
    else if( value.compareTo(curr.item) < 0 )        // Try the left  subtree right if <
        curr.left = removeFromTreeHelper( value, curr.left );     
    else if( value.compareTo(curr.item) > 0 )        // Try the right subtree right if >
        curr.right = removeFromTreeHelper( value, curr.right);     
    else // We have found the value to be removed.
         // Does it have two descendants, or only one, or is it a leaf?
     if( curr.left != null && curr.right != null )
        // Two descendants. Move the smallest value greater than value
        // up and delete the node that contianed it recursively.
        curr.item = findMin( curr.right).item;
        curr.right = removeFromTreeHelper( curr.item, curr.right );
    else // Only one descendant. Move it up. This also works if a leaf.
        if( curr.left != null )
            curr = curr.left;
        else
            curr = curr.right;
    ok = true;
    return curr;
  }This part is killing me. How can this be done with < T > (Generic).
  // Two descendants. Move the smallest value greater than value
        // up and delete the node that contianed it recursively.
        curr.item = findMin( curr.right).item;
        curr.right = removeFromTreeHelper( curr.item, curr.right );
     }I need to pass T value not curr.item, is there a work around here?
Message was edited by:
venture
Message was edited by:
venture

Is this even possible or would it be best to go ahead and make a whole new method for removal? 3 hours of staring at this code and Im right back where I started.

Similar Messages

  • BW IP: API's comparably methods in IP

    Hello together,
    in BPS is the function group UPC_API. With these functions, read and written plan data can be planning-variable read and set.
    API_SEMBPS_ADHOCPACKAGE_SET
    API_SEMBPS_AREA_GETDETAIL
    API_SEMBPS_CHA_VALUES_GET
    API_SEMBPS_CHA_VALUES_UPDATE
    API_SEMBPS_FUNCTION_EXECUTE
    API_SEMBPS_GETDATA
    API_SEMBPS_GLSEQUENCE_EXECUTE
    API_SEMBPS_HIERARCHY_GET
    API_SEMBPS_LAYOUT_GETDETAIL
    API_SEMBPS_PACKAGE_GETDETAIL
    API_SEMBPS_PLANSTRUCTURE_GET
    API_SEMBPS_PLEVEL_GETDETAIL
    API_SEMBPS_POST API_SEMBPS_REFRESH
    API_SEMBPS_SEQUENCE_EXECUTE
    API_SEMBPS_SETDATA
    API_SEMBPS_VARIABLE_GETDETAIL
    API_SEMBPS_VARIABLE_SET
    Question:
    Is there in the integrated planning comparably methods and can someone send me examples?
    Many greetings
    Christian

    Dear Gregor,
    this is an interesting question which I am confronted with myself.  U indicated that there is not much need for these API's, but how do you retrieve the value of a variable within the logic of an exit function (implemented in rsplf1) in IP?
    I cannot see that the normal BEx exit variable logic (I_STEP = 2 in include ZXRSRU01) would be applicable.
    This used to be possible with API_SEMBPS_CHA_VALUES_GET.
    Greetings,
    Martin

  • MyInteger class- compile error - method doesnt implement comparable method

    I am trying to test how the code for a hash table works- I have 4 classes
    Hashable interface
    QuadraticProbableHashTable
    HashEntry
    MyInteger
    Everything is compiling but one error comes up saying that "Class must implement the inherited abstract method Comparable.compareTo(object)."
    I have a comparable method with the same signature as that in Comparable interface; in MyInteger.java where the problem is. However I still have the same problem.
         * Wrapper class for use with generic data structures.
         * Mimics Integer.
        public final class MyInteger implements Comparable, Hashable
             * Construct the MyInteger object with initial value 0.
            public MyInteger( )
                this( 0 );
             * Construct the MyInteger object.
             * @param x the initial value.
            public MyInteger( int x )
                value = x;
             * Gets the stored int value.
             * @return the stored value.
            public int intValue( )
                return value;
             * Implements the toString method.
             * @return the String representation.
            public String toString( )
                return Integer.toString( value );
             * Implements the compareTo method.
             * @param rhs the other MyInteger object.
             * @return 0 if two objects are equal;
             *     less than zero if this object is smaller;
             *     greater than zero if this object is larger.
             * @exception ClassCastException if rhs is not
             *     a MyInteger.
            public int compareTo( Comparable rhs )
                return value < ((MyInteger)rhs).value ? -1 :
                       value == ((MyInteger)rhs).value ? 0 : 1;
             * Implements the equals method.
             * @param rhs the second MyInteger.
             * @return true if the objects are equal, false otherwise.
             * @exception ClassCastException if rhs is not
             *     a MyInteger.
            public boolean equals( Object rhs )
                return rhs != null && value == ((MyInteger)rhs).value;
             * Implements the hash method.
             * @param tableSize the hash table size.
             * @return a number between 0 and tableSize-1.
            public int hash( int tableSize )
                if( value < 0 )
                    return -value % tableSize;
                else
                    return value % tableSize;
            private int value;
        }

    >
    You might want to also allow for cases where the
    value passed in is null, or the argument to the
    method is NOT a MyInteger object :-)
    Just a small note - the javadocs for Comparable#compareTo says the following:
    Throws:
    ClassCastException - if the specified object's type prevents it from being compared to this Object.
    So it's perfectly OK to blindly try to cast to the desired type in the sense that you are not violating the Comparable contract if the cast fails.

  • The fillArc method (question about)

    Hi all,
    I'm studying basics of awt Graphics. Now i'm trying to use the fillArc method, but I found something that make me a question...
    So, I'm trying to draw a arc sucession, but I don't understand some parameters that are different of the rect delimiter. I used the drawArc method also to see the diferences.
    Here is part of the code (please see the comments in loop for):
    public class DesenhaArco extends JPanel{
    final Color VIOLETA = new Color(128, 0, 128);
    final Color AZULMARINHO = new Color(75, 0, 130);
    private Color colors[] = {Color.WHITE, Color.WHITE, VIOLETA, AZULMARINHO, Color.BLUE,
    Color.GREEN, Color.YELLOW, Color.ORANGE, Color.RED};
    public DesenhaArco(){
    setBackground(Color.WHITE);
    public void paintComponent(Graphics g){
    super.paintComponent(g);
    //obtain the width center
    int centerX = getWidth() / 2;
    int arcEspessure;
    //calculate the arcs espessure based in panel metrics
    if (getHeight() > getWidth()){
    arcEspessure = getWidth() / (colors.length * 2);
    else {
    arcEspessure = getHeight() / colors.length;
    if (arcEspessure * colors.length * 2 > getWidth()){
    arcEspessure = getWidth() / (colors.length * 2);
    for (int contArco = colors.length; contArco > 0; contArco--){
    g.setColor(Color.BLACK);
    //draw a rect delimiter with black borders to test
    g.drawRect(centerX - arcEspessure * contArco, getHeight() - arcEspessure * contArco,
    arcEspessure * contArco * 2, arcEspessure * contArco);
    g.setColor(colors[contArco - 1]);
    //here is the problem (above, in fillArc)
    //the x, y, width and height parameters is equals the parameters of drawRect method,
    //but results in arcs with only part of the height inserted in height argument
    //if I multiplicate the height argument (4th parameter) for 2
    //(arcEspessure * contArco * 2) I obtain the correct results
    //but I think this is'nt a correct mode...
    g.fillArc(centerX - arcEspessure * contArco, getHeight() - arcEspessure * contArco,
    arcEspessure * contArco * 2, arcEspessure * contArco, 0, 180);
    }Sorry for my wrong english.
    Thanks. :-)

    "The center of the arc is the center of the rectangle whose origin is (x, y) and whose size is specified by the width and height arguments." (JSE 6 API Specification)
    I think I have understanded... The Y start point of an arc begins in center of height metric.
    So I changed the arguments of fillArc method, specificatly the 2th and 4th parameters, making an rectangle delimiter with double of the metrics that I need and starting out of the panel delimiters (1/2 out panel):
    g.fillArc(centerX - espessuraArco * contArco, -contArco * espessuraArco,
    espessuraArco * contArco * 2, espessuraArco * contArco * 2, 0, -180);Thanks for all. :-)

  • Is it possible to create a generic report that accepts the SQL as a param

    Is it possible to create a generic report that accepts the FULL sql statement as a paramater and returns variable results based on this?
    We have a requirement to have a generic export routine to spit out csv's from clicking on a web page hyperlink, which would need to accept a "new" sql statement for every run, each containing different columsn etc that would be needed in the output.
    I was hoping could have a generic Oracle report, exporting delimited data format (and as such not using a layout) and somehow pass in the "new" sql statement as a parameter at run time - each sql statement would be different with different columns etc.
    Is this possible with oracle reports ?
    thanks

    If you need a simple dump of data you could try writing a report with a simple query such as
    select 'Report title or column headers'
    from dual
    &data_query
    then your &data_query parameter could be
    union select col1||','||col2 from data_table
    If you are outputing a comma separated data dump the you can concatenate together your data into a single text field.
    This would allow you to have a simple heading followed by the actual data. I guess you could extend this so that the 'Report title or column headers' from the first query was also a parameter to output your row headings i.e.
    select :column_headings_text
    from dual
    &data_query
    Give it a go and good luck

  • HT201359 i have a problems while purchasing or download a free item in apps store or itunes, it said that you have a problems with previous purchase, it also said that my payment method was decline.,..

    i have a problems while purchasing or download a free item in apps store or itunes, it said that you have a problems with previous purchase, it also said that my payment method was decline.,..

    Hi shldr2thewheel,
         it has been a while since we have last spoke, I would like to let you know, I am still working on getting used to the switch from windows to a Mac/Apple system. I do have a new question for you, I did purchase In Design CS5.5 through journeyed.com through Cuyahoga Community College of which I attend as a student, is there a way to purchase an online book through iTunes to learn that as well? Also, you know me, the struggling student, I would also, when and if the book can be purchased through the iTunes, would need to know if you do know of a much easier book for struggling students like myself and at a reasonable price as well for the In Design CS5.5 program. Our campus bookstore had closed early, and, so did the colleges library and our local library here where I do live, so, I cannot go to either place to purchase a book or to take out a book, plus cash funds are low at this moment as well but, I do have money left on the iTunes account to use, if it can be used. So, can it be used, the iTunes money, towards finding a low priced online book? I am in great need of assistance as I have a project due for my one course for this Tuesday, September 4, 2012.
    Sincerely in need of help once again,
    Kim

  • Compare methods in C # to connect to SQL Server database in terms of speed,quality and functionality.

    Please compare
    methods in C # to connect to SQL Server
    database (for example,
    3-tier architecture of traditional and 
    entity Framework(linq to entity or linq to sql object model)
    and Linq to SQL) in terms of speed, quality and functionality
    to give me tips.
    Thank you.
    Mojtaba Malakouti.

    That means we need to compare and post the results here?
    Best Regards,Uri Dimant SQL Server MVP,
    http://sqlblog.com/blogs/uri_dimant/
    MS SQL optimization: MS SQL Development and Optimization
    MS SQL Consulting:
    Large scale of database and data cleansing
    Remote DBA Services:
    Improves MS SQL Database Performance
    SQL Server Integration Services:
    Business Intelligence

  • Help and some explanation how to get a Microsoft.Office.Tools.Excel.Worksheet host item that extends the functionality of the current Microsoft.Office.Interop.Excel.Worksheet object

    Hello,
    I would use some help and more info about how to get host object that extends the functionality of my current Interop.Excel.Worksheet object. I read this artical: https://msdn.microsoft.com/en-us/library/ee794671.aspx where I can call this function
    GetVstoObject to get host object. But I see that here I need to pass the Globals.Factory object as second parametar. Can someone give me more details about that parameter and how to access it? I would like to get host object so I can access extension
    property, since my interop excel worksheet doesn't have it.  
    I am using Visual Studio 2013 for developing Excel addin. Using Excel 2010.
    Thanks in advance for help.
    Regards,
    Zeljka

    Hi Zeljka,
    >>I am using the Microsoft Office PIAs, so my question is how to access this automatic generated class Globals in my case?   <<
    Sorry, I am not able to understand the application you were developing exactly. From the orgnal post, you were developing an application level add-in, however based on the description above, it seems that you were building an console or Windows form application
    to automate Office application.
    If you were developing Office automation, the host item can't work for this secnario since it should run under the VSTO runtime.
    If I misunderstood, please feel free to let me know.
    Regards & Fei
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • Namespace, static method questions

    The really useful script here is
    Sephiroth's
    Actionscript 3 PHP Unserializer. I have used the old AS2
    version many times and it's totally rad. With it you can create
    really complex data objects in php,
    serialize() them, and then
    unserialize them with this code in Flash. It dramatically reduces
    the amount of code you have to write to share complex data between
    PHP and Flash.
    The problem I'm having is that the new Actionscript 3 version
    was apparently written for Flex. When I try to use it in flash, I
    get an error:
    1004: Namespace was not found or is not a compile-time
    constant.. This error refers to this line of code:
    use namespace mx_internal;
    I know next to nothing about namespaces in Flash, but best I
    can tell, that namespace constant is apparently to be found in
    mx.core.
    At any rate, if I remove all references to mx_internal
    namespace and mx.core, I can get the script working. This brings me
    to my first questions:
    QUESTION 1: What does the use of that namespace stuff
    accomplish?
    QUESTION 2: Am I likely to suffer any unpredictable consequences
    by removing that namespace stuff?
    Also, I get an error (1061: Call to a possibly undefined
    method serialize through a reference with static type
    org.sepy.io:Serializer.) when I try to call the static methods of
    the Serialize class by instantiating it and calling the methods via
    the instance like this:
    var oSerializer:Serializer = new Serializer();
    var str = oSerializer.serialize(obj);
    That's my third question:
    QUESTION 3: Is it impossible to call a static method of a class
    from an instance of the class? Do we have to reference the class
    name instead?
    Any help would be much appreciated

    nikkj wrote:
    static methods are really class messages, that is, methods that act upon an entire classification of objects not just one instance. it is an elegant means by which to send messages to all instances or rather the class itself
    Static method calls are determined at compile time,not at run time, so it is not possible for the invocation to be polymorphic.(i.e can't be overridden)
    Because the language is defined that way - via the JLS.
    There is no technological reason that precludes a language from doing it. Smalltalk does exactly that.

  • The App Store say that my payment method is declined why and it was ok before

    The App Store say that my payment method is declined why and it was ok before

    Apple doesn't answer questions here. Everyone here is a user so we wouldn't know about why there is an issue with your account. If it is a bank card, then you need to check with the bank.

  • Need help in compare method of Comparator class

    I am writing a program that will display elements of a TreeMap in an order in which I want. By default the order is ascending. To change the order I need to override the compare method of the Comparator class.
    I've done this in my code below.
    I want to display keys with lower-case 1st and then those with upper-case.
    Please help.
    import java.util.*;
    public class MyComparator implements Comparator {
      public int compare(Object o1, Object o2) {
        String s1 = o1.toString();
        String s2 = o2.toString();
        return s1.compareTo(s2);
      public static void main(String[] args) {
        Map names = new TreeMap(new MyComparator());
        names.put("a", new Integer(1435)); 
        names.put("b", new Integer(1110));
        names.put("A", new Integer(1425));
        names.put("B", new Integer(987));
        names.put("C", new Integer(1323));   
        Set namesSet = names.keySet();
        Iterator iter = namesSet.iterator();
        while(iter.hasNext()) {
          String who = (String)iter.next();
          System.out.println(who + " => " +     names.get(who));
    }

    public int compare(Object o1, Object o2) {
        String s1 = o1.toString();
        String s2 = o2.toString();
        String ss1 = beginsWithLowerLetter(s1)? s1.toUpperCase() : s1.toLowerCase();
        String ss2 = beginsWithLowerLetter(s2)? s2.toUpperCase() : s2.toLowerCase();
        return ss1.compareTo(ss2);
    }

  • Overloaded methods question

    I guess I don't understand overloaded methods as well as I thought I did, because I'm confused about some behavior I'm seeing in my Java program. Here's a sample program that I wrote up to demonstrate the issue:
    public class Polymorphism
         static class Shape
              public void test()
                   System.out.println( "In Shape" );
         static class Rectangle extends Shape
              int height, width;
              public Rectangle( int height, int width )
                   this.height = height;
                   this.width = width;
              public void test()
                   System.out.println( "In Rectangle" );
              public boolean equals( Rectangle rect )
                   return ( height == rect.height ) && ( width == rect.width );
         public static void main( String[] args )
              Shape shape = new Rectangle( 5, 7 );
              shape.test();
              Shape shape1 = new Rectangle( 3, 4 );
              Shape shape2 = new Rectangle( 3, 4 );
              System.out.println( shape1.equals( shape2 ) );
              System.out.println( ((Rectangle)shape1).equals( shape2 ) );
              System.out.println( shape1.equals( (Rectangle)shape2 ) );
              System.out.println( ((Rectangle)shape1).equals( (Rectangle)shape2 ) );
    }And the output looks like this:
    In Rectangle
    false
    false
    false
    trueThe first call to "test()" calls the Rectangle's test method, as I would have expected. This happens despite the fact that shape is declared as a Shape.
    Here's where I get confused. I would have thought the next four calls to println would have output "true" every time, because shape1 and shape2 are Rectangles, hence, I would have expected that Rectangle's "equals()" method would have been called each time. But apparently it's only being called in the last case, when I cast both shape1 and shape2 to be Rectangles. (Presumably, Object.equals() is being called, and it's appropriately returning "false" because the objects are not the same instance.)
    So this behavior seems inconsistent to me. Why did the first call to "test()" invoke Rectangle.test() even though I declared it as a Shape, yet the succeeding calls to shape1 invoke Shape.equals() rather than Rectangle.equals(), despite the fact that the objects are truly Rectangles?
    Can anyone explain this to me, or point me to a tutorial that would describe this behavior?
    Thanks.

    Case 1 and Case 2 seem analogous to me, yet their
    behaviors are different. (There is one difference
    between the two cases, and that is that in case 1 I'm
    overriding the test() method, while in case 2 I'm
    overloading equals(). Overriding vs. overloading.
    Though clearly these are different concepts, I guess
    it never would have occurred to me that whether a
    method was overridden vs. overloaded made such a
    difference in how invocation worked.)You're right: it's the diffference between overriding and overloading.
    I'll try to formulate it differently:
    At compile-time, the compiler, based on the declared type of the Object the method's called on, and based on the declared types of the arguments, determines which method'll get called (a method is defined by its name and its signature. I don't think the return type matters in this context).
    In the test() case, the compiler looks for a method in class Shape and finds: test().
    In your "third case", the compiler looks for a method named "equals" in class Shape with the argument type: "Rectangle", finds none, so it takes: equals(Object)
    At runtime, the method is looked for in the Object it's invoked on, that is a Rectangle.
    In the test() case, it looks for the method: test(). Since that is declared in the Rectangle class, it takes the overridden method.
    But in the "third case", there's no equals(Object) method, so it takes the super.
    So I apologize if no one can think of a way to make
    this clearer to me, but I still have some subtle
    confusion on the issue.It is a confusing topic. That's why I pointed out itchyscratchy's reply, who made a good point telling to avoid having to rely on overloaded methods generally. Overriding is complicated enough.

  • Extending UIComponent, createChildren question

    All,
    I'm trying to make some simple components.  For the sake of making this exercise very simple, I'm using a callout control from Adobe posted here.
    http://www.adobe.com/devnet/flex/samples/fig_callout/
    The source of that component can be viewed here:
    http://www.adobe.com/devnet/flex/samples/fig_callout/srcview/index.html
    More specifically, I'm looking at the src/AirportCallout.mxml file.
    I'm looking at making a class that extends UIComponent.
    public class AlertWrapper extends UIComponent
            private var callout : Callout;
            public function AlertWrapper(){
                super();
                this.buttonMode = true;
                //this.addEventListener(MouseEvent.CLICK, alertClicked);
                this.graphics.drawCircle(25, 25, 5);
           override protected function createChildren():void{
                super.createChildren();
                this.callout = new Callout();
                this.callout.x = 25
                this.callout.y = 25;
                this.addChild(this.callout);
            override protected function measure():void{
                super.measure();
    This is obviously a very simple example dumbed down for the sake of figuring out what's going on.  I'm drawing a circle at point (25, 25) with a radius of 5.  I'm then trying to place a callout component (something that adobe made and works well) onto this component as a child.
    When I add an instance of the AlertWrapper class to the display list (In the real world situation, I add it to a container using the addChild method), it does not render the callout correctly (it's the wrong size, much smaller than it should be).  I'm stumped trying to figure out why this is.  If I look at the AirportCallout.mxml class, I see that it isn't given a size by default.  If I give it a size of 200, it does render correctly (albeit the wrong size).
    Can anyone shed any light of this?  I'm new to designing my own controls that extend UIComponent.
    Thanks,
    Dan

    public class AlertWrapper extends UIComponent
             private var callout : Callout;
            public function  AlertWrapper(){
                super();
                this.buttonMode =  true;
                //this.addEventListener(MouseEvent.CLICK,  alertClicked);
                this.graphics.drawCircle(25, 25, 5);
            override protected function createChildren():void{
                 super.createChildren();
                this.callout = new Callout();
                 this.callout.x = 25
                this.callout.y = 25;
                 this.addChild(this.callout);
             override protected function measure():void{
                 super.measure();
                this.measuredHeight = this.callout.getExplicitOrMeasuredHeight();
                this.measuredWidth = this.callout.getExplicitOrMeasuredWidth();
    Doing something like this does not render correctly.  It looks cut off like this.
    var alertWrapper : AlertWrapper = new AlertWrapper();
    var canvas : Canvas = new Canvas();
    canvas.addChild(alertWrapper);
    When debugging, the alertWrapper measuredHeight and measuredWidth are set to 35 and 32.
    It looks like this
    If I change the code in alertWrapper and change the createChildren and measure functions to as follows, I can hack my way through it:
    override protected function createChildren():void{
                 super.createChildren();
                this.callout = new Callout();
                 this.callout.x = 25
                this.callout.y = 25;
                //  this.addChild(this.callout);
             override protected function measure():void{
                 super.measure();
                // this.measuredHeight =  this.callout.getExplicitOrMeasuredHeight();
                 // this.measuredWidth =  this.callout.getExplicitOrMeasuredWidth();
    Then, if I add it to my container as such, it renders correctly but I don't understand why.  When I debug with this second method, the measuredWidth and measuredHeight of the alertWrapper are both 0 (which is weird since the circle is being drawn).
    var alertWrapper : AlertWrapper = new AlertWrapper();
    var canvas : Canvas = new Canvas();
    canvas.addChild(alertWrapper);
    canvas.addChild(alertWrapper.callout);
    This second method seems very hacky and I would like to understand what I have to do to make it work so I only have to add the alertWrapper to the container to get it to render correctly.  Please help!

  • Assigning ThreadGroup to a Class that Extends Thread

    How can i assign a thread group to a class running as a thread that extends thread without changing the class to implement Runnable?
    An Example of the application format:
    public class Application implements Runnable
    private ThreadGroup main = new ThreadGroup("Main");
    private Thread mainThread = null;
    public Application()
    public void start()
    if (mainThread == null)
    mainThread = new Thread(main,"main")
    mainThread.start();
    public void run()
    Thread current = Thread.currentThread();
    while(current != null)
    while(something to do)
    AThread a = new AThread();
    a.start();
    String aData = a.getData();
    BThread b = new BThread(data);
    b.start();
    String bData = b.getData();
    class AThead extends Thread
    public AThread()
    //What to do with AThread to assign it to a thread group?
    public void run()
    Basically the application works form a main constructor class running the application class as a thread. The application class will then launch AThread and BThread as subthreads. I would like to be able to count how many of each type of thread is running for the AThread and BThread. I tried using AThread and BThread implementing Runnable to create a thread under a group but it wouldn't work. The application class needs to get information from the AThread and BThread threads once the thread was done, but if the AThread and BThread was implementing Runnable, the Applicaiton Class can't get the data or run methods. Is there some way i can assign what thread group AThread and BThread will run as in thier class files and not the Application class?

    See: http://java.sun.com/j2se/1.4/docs/api/java/lang/Thread.html#Thread(java.lang.ThreadGroup, java.lang.String)
    I think this does what you want:
    public class Application implements Runnable
    private ThreadGroup main = new ThreadGroup("Main");
    private ThreadGroup aThreads = new ThreadGroup("AThreads"); // Added a thread group for all AThread objects
    private Thread mainThread = null;
    public Application()
    public void start()
      if (mainThread == null)
        mainThread = new Thread(main,"main")
        mainThread.start();
      public void run()
        Thread current = Thread.currentThread();
        while(current != null)
          while(something to do)
            AThread a = new AThread(aThreads);  // Create an AThread that will belong to aThreads ThreadGroup
            a.start();
            String aData = a.getData();
            BThread b = new BThread(data);
            b.start();
            String bData = b.getData();
    class AThead extends Thread
      public AThread(ThreadGroup group)
        super(group, "AThread"); // This will make a new Thread that belongs to ThreadGroup group, see link above
      public void run()
    }

  • Interfaces that extend other interfaces

    I am trying to get a handle on the concept of interfaces extending other interfaces, and I just want to bounce my thoughts off the board and see where it goes. The Sun tutorial doesn't provide a lot of detail that I can see.
    Suppose we have interface A which has 3 methods (signatures), and interface B which extends interface A and adds two methods of its own. Suppose also we have a class C which can implement A or B or both.
    1. Having B extend A provides a heirarchy of types, with A above B
    2. If class C implements interface B, then the extends relationship B has with A forces C to provide implementations for the methods of A as well as B. On this point I am not certain.
    3. Having B extend A allows us to essentially add methods to the interface defined by A without forcing those changes on owners of the classes that already extend A.
    Sound OK? Anywone have anything to add?
    Edited by: Fguy on Aug 27, 2009 7:07 PM

    jverd wrote:
    Fguy wrote:
    >
    3. Having B extend A allows us to essentially add methods to the interface defined by A without forcing those >>changes on owners of the classes that already extend A.Huh? Not sure what you're saying, here, but extending A means we're defining a type that's a specialized or >enhanced type of A. Implementors can implement A if all they need is a run of the mill A, or B if they need the >specialized/enhanced version.Thanks.
    What I meant was that class C implements interface A, and interface B is not a part of the picture yet. Then, by creating a new interface B that extends A, rather than just adding the new methods to A, then you are not forced to add new method implementation to class C right away.That would be one situation in which one might do that. Of course, it's also not uncommon to design the two distinct interfaces from the start
    Ok I'll pick up on that, the situation that led to this thread was me trying to understand why the List interface extends the Collection interface, and why the ArrayList class implements both interfaces. And I eventually decided that designing kind of an arrangement makes sense from the start as you say, because there are probably reasons why you'd want that type heirarchy, or higher level abstraction. with different levels of functionality in the respective implementations. I can't really think of any other reason.

Maybe you are looking for

  • Which perspectives I should consider about Av Rd(ms) is very high just for

    db version: 11.1.7 os: RH linux 5.5 I was seeing i/o stats from AWR generated for one hour, and all the value of Av Rd(ms) for files i/o stats are under around 10, however except for one file, the Av Rd(ms) just for one data file is very high(38325.2

  • Errors in my listener.ora file

    oracle 10.2 windows xp database run locally on my PC. just a test DB. I get errors when i try to start the listener pointing to the sidlist_listener line? SID_LIST_LISTENER =   (SID_LIST =     (SID_DESC =       (SID_NAME = PLSExtProc)       (ORACLE_H

  • Error when install wlss22 on solaris 10 x86

    encountered error during installation of wlss22 (solaris build) on my solaris 10 x86 pls help $./wlss220_solaris32.bin bash: ./wlss220_solaris32.bin: Invalid argument

  • Music and slideshow

    How do you have iphoto via itunes, continue to play more than the one song you can choose from your collection, so that in lond slide shows the some song doesn't keep on playing?? Thanks, GH

  • Restore deleted files from time capsule. how???

    Hi all, by mistake I deleted some important files in Time Capsule. Does it exist the way how to restore it?