Override Methods In NetBeans IDE

12 April 2007

NetBeans has a very rich set of features which allow users to generate code or templates. There are a variety of cases where user can generate code using NetBeans IDE. Here we will discuss an easy way to generate overriding methods in sub classes.

Suppose you have two classes. “Car” and “FourWheeler”.

/* * FourWheeler.java*
 
* Created on April 11, 2007, 10:30 PM
 
*
 
* To change this template, choose Tools | Template Manager
 
* and open the template in the editor.
 
*/package javatips;
 
public class FourWheeler {
 
/** Creates a new instance of FourWheeler */
 
public FourWheeler() {
 
}
 
/**
 
* Holds value of property capacity.
 
*/
 
private int capacity;
 
/**
 
* Getter for property capacity.
 
* @return Value of property capacity.
 
*/
 
public int getCapacity() {
 
return this.capacity;
 
}
 
/**
 
* Setter for property capacity.
 
* @param capacity New value of property capacity.
 
*/
 
public void setCapacity(int capacity) {
 
this.capacity = capacity;
 
}
 
}
 
Car. Java
 
package javatips;
 
public class Car extends FourWheeler{
 
/** Creates a new instance of Car */
 
public Car() {
 
}
 
/**
 
* Holds value of property color.
 
*/
 
private String color;
 
/**
 
* Getter for property color.
 
* @return Value of property color.
 
*/
 
public String getColor() {
 
return this.color;
 
}
 
/**
 
* Setter for property color.
 
* @param color New value of property color.
 
*/
 
public void setColor(String color) {
 
this.color = color;
 
}
 
}

Now you want that Car class which extends FourWheeler should override methods of FourWheeler class. Then Follow these steps.

  1. Select Source - > “Override Methods” or press “Ctrl+I”. You will see following screen.
  2. On clicking the below screen appears.
  3. Select the methods you want to override. Code will be automatically generated.
  4. package javatips;public class Car extends  FourWheeler{
     
    /** Creates a new instance of Car */
     
        public Car() {
     
        }
     
    /**
     
         * Holds value of property color.
     
         */
     
        private String color;
     
    /**
     
         * Getter for property color.
     
         * @return Value of property color.
     
         */
     
        public String getColor() {
     
            return this.color;
     
        }
     
    /**
     
         * Setter for property color.
     
         * @param color New value of property color.
     
         */
     
        public void setColor(String color) {
     
            this.color = color;
     
        }
     
    public void setCapacity(int capacity) {
     
            super.setCapacity(capacity);
     
        }
     
    public int getCapacity() {
     
            int retValue;
     
    retValue = super.getCapacity();
     
            return retValue;
     
        }
     
    }

del.icio.us:Override Methods In NetBeans IDE digg:Override Methods In NetBeans IDE spurl:Override Methods In NetBeans IDE wists:Override Methods In NetBeans IDE simpy:Override Methods In NetBeans IDE newsvine:Override Methods In NetBeans IDE blinklist:Override Methods In NetBeans IDE furl:Override Methods In NetBeans IDE reddit:Override Methods In NetBeans IDE fark:Override Methods In NetBeans IDE blogmarks:Override Methods In NetBeans IDE Y!:Override Methods In NetBeans IDE smarking:Override Methods In NetBeans IDE magnolia:Override Methods In NetBeans IDE segnalo:Override Methods In NetBeans IDE gifttagging:Override Methods In NetBeans IDE

Top Of Page | Trackback

If you found this page useful, consider linking to it. Simply copy and paste the code below into your web site.

It will look like this: Override Methods In NetBeans IDE

Leave a Reply

buy cialis buy viagra cialis, viagra, levitra buy levitra buy clomid order cialis order levitra order viagra online viagra online cialis online levitra viagra prescription buy cialis online buy viagra online buy levitra online buy clomid online cialis soft tabs buy cialis soft tabs viagra online cialis online order viagra online order cialis online order levitra online
Professional Medicines, Online Pharmacy buy clomid buy viagra buy cialis buy tramadol buy soma buy levitra buy propecia buy ultram buy acomplia buy phentermine buy xenical buy kamagra Online Pharmacy Products