that do all sorts of useful work before returning the element. You are free to use any elements at your disposal to derive a value for the method to return. For example: public SomeClassOrPrimitiveType getAnInstanceVariable() { Class1 objectClass1 = new Class1() ; SomeClassOrPrimitiveType aVar = objectClass1AnotherMethod ( objectClass1, anotherElement ) ; return aVar ; } In the preceding example a new object is created and another method queried before the final value, aVar is returned to the caller. You may also have get methods that don’t query an specific instance variable. For example, if you have a bean with the boolean property networkUp, the method isNetworkUp would query the network and return a result based on the status of the network. In practice, many get methods just return the current value of the instance variable. Much of the manipulation of setting instance variable values is done in “set” methods. Set, or mutator, methods enable a bean user to change the value of a bean property. Here s an example modeled after the get method above: public void setAnInstanceVariable(SomeClassOrPrimitiveType aVar) { anInstanceVariable = aVar ; } Notice the following about the set method: . The set method is declared public. . The set method returns void. . The set method takes one argument of the same class or primitive type as the instance variable. . The name of the get method is the word “set” followed by the name of the instance variable with the first letter of the variable name capitalized. Notice that setAnInstanceVariable, anInstanceVariable is set to the value of aVar which was passed into the method. While it is not a requirement of the set method that it contain one or more assignment statements, this is usually the case. You don t need to write both get and set methods for a bean property. If your JSP or Java code doesn t need to change a bean property, then you shouldn t create a set method for that property. The following section takes a quick look at coding accessor methods for indexed bean properties. Coding Accessor Methods for Indexed Bean Properties The basic idea and rationale for coding get and set methods for indexed properties is the same as those for non- array properties. Needing some mechanism for accessing an array element, consider the following indexed property declaration: private SupportedType[] anArrayOfThisType ; Then the method header would appear as follows: public SupportedType getAnArrayOfThisType( int arrIndex )
File Transfer Protocol comes together with anonymous ftp access with every FTP Web Hosting account we offer today. Enjoy burs table ftp transfers together with fast FTP connection.

Leave a Reply