Type casting the returned value of a method.

Type casting the returned value of a method.

Hi,

How do you type cast the returned value of a method so that you can avoid creating a temporary variable. Here's an example:

panel.getComponent(i).(OnOffButton)setState('0');

I know that the component returned by panel.getComponent(i) will be of type OnOffButton. I want to avoid:

OnOffButton btn = (OnOffButton) panel.getComponent(i); btn.setState('0');

Is there a way around this?

Thanks,

Justin

View Answers

November 15, 2010 at 5:26 AM

Hi,

You may try following code:

((OnOffButton) panel.getComponent(i); btn.setState('0')).setState('0');

Thanks


November 16, 2010 at 3:02 PM

Hi,

That doesn't work. (Also, i'm trying to avoid creating the btn variable in the first place).

Thanks









Related Tutorials/Questions & Answers:
Type casting the returned value of a method.
Type casting the returned value of a method.  Hi, How do you type cast the returned value of a method so that you can avoid creating a temporary..._TO_REPLACE_1 I know that the component returned by panel.getComponent(i
type casting
type casting  what is type casting
Advertisements
Type casting
Type casting  how to type cast a string value to byte array
type casting
type casting  int n=20; n=sizeof((char)(float)n); what is n value
type casting
type casting  <--bean class-->method calllist is of object type... List (object type) <Object> totalList(int pi){ (adsbygoogle = window.adsbygoogle || []).push({}); try{ Query q= em.createQuery
type casting purpose
type casting purpose  what is type casting , could u explain with practical example
type casting - Java Beginners
type casting and conversion  I am beginner and my query is Importance of type casting and conversion  Hi friend,public class TypeCasting...;Value of b after conversion : " + b); //Convert from boolean to short. s
Type casting in java
Type casting in java In this section you will learn about type casting in java. Type casting is to convert one type to another type. Java support two types of casting; primitive type and reference type casting. Reference type casting
Java type casting
Java type casting  Can a Byte object be cast to a double value
ModuleNotFoundError: No module named 'type-casting'
ModuleNotFoundError: No module named 'type-casting'  Hi, My Python... 'type-casting' How to remove the ModuleNotFoundError: No module named 'type-casting' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'type-casting'
ModuleNotFoundError: No module named 'type-casting'  Hi, My Python... 'type-casting' How to remove the ModuleNotFoundError: No module named 'type-casting' error? Thanks   Hi, In your python
Java Type Casting - Java Beginners
Java Type Casting  what is object type casting? give some example with related
Java type casting
Java type casting  What is Downcasting
java type casting problem - Java Beginners
java type casting problem  what is type casting? what is the type of type casting? explain with example?  Hi Friend, Please visit the following link: http://www.roseindia.net/java/beginners/TypeCasting.shtml
unable to get value returned from javascript variable in page
unable to get value returned from javascript variable in page  Hi, I have 3 pages....i wrote a js function to get the value of radio button from one jsp page..what i want is to store the value returned from the js function
Casting (Type Conversion)
Casting (Type Conversion)      ... casting. In java one object reference can be type cast into another object reference. This casting may be of its own type or to one of its subclass or superclasss
What is the return type of the main method?
What is the return type of the main method?  hi, What is the return type of the main method? thanks   Hi, In the java programming the Main() method doesn't return anything hence declared void. In Java, you need
The method buildServiceRegistry() is undefined for the type ServiceRegistryBuilder
The method buildServiceRegistry() is undefined for the type ServiceRegistryBuilder  Hi, How to solve the error "The method buildServiceRegistry() is undefined for the type ServiceRegistryBuilder" in Hibernate 4.3.1? I am using
Method is undefined for the type Object(org.apache.jasper.JasperException)
Method is undefined for the type Object(org.apache.jasper.JasperException) .../bap/editPracticeRevenuSplit.jsp Generated servlet error: The method getPracticeRevenueCode() is undefined for the type Object
java method return type : - Java Beginners
java method return type :  i have one question regarding methods,,, if we create a method with return type as class name (public employee addemp(int,int))what should be its return type.....and if any know this pls explain
Java Method Return Value
Java Method Return Value       Java  method Return Value return to the code when... the value within the body of method. The method declared void does not return any
What is casting?
What is casting?   Hi, What is casting? thanks
Java bigdecimal setScale method example
working is demonstrated. Method return type is a bigdecimal value therefore... value is numerically equal to the object value in which the method is invoked. Scale... the returned value is numerically equivalent to this.object value.  While running
Java BigDecimal floatValue method example
Java BigDecimal floatValue method example       Java bigdecimal class floatValue() method translates bigdecimal value in to float type value. Method throws 
Problem with Double type Value in Access Database - Java Beginners
Problem with Double type Value in Access Database  Hello sir I have store Double Type Value in MS Access Databse,but when I search Record then it Gives Round Figure Value related with Percentage and I want to Store and Retrieve
Remove a value with remove() method
Remove a value with remove() method     ... by a index value using the remove() method. Specify the index position from where... a particular position specified by a  index value. Here is an example
PHP Type Juggling
a float value to a variable then it becomes float type and if we assign...;; echo "Value of temp is:".$temp." and data type is: "...;Value of temp is:".$temp." and data type is: ".gettype($temp
JDOM Attribute Example, How to convert value of attribute in different data type
JDOM Attribute Example, How to convert value of attribute in different data type In this tutorial, we will see how to retrieve the value...()  method of the org.jdom.Attribute class returns the text value
Casting in java - Java Beginners
Casting in java   Hi, I want to know Casting in detail... is implicit casting and Explicit casting . Implicit casting : Ex - assign... Explicit casting : Ex - Assign superclass variable to subclass
ModuleNotFoundError: No module named 'returned-manager'
ModuleNotFoundError: No module named 'returned-manager'  Hi, My... named 'returned-manager' How to remove the ModuleNotFoundError: No module named 'returned-manager' error? Thanks   Hi, In your
JavaScript getAttributeNode method
() method. We have created one div component and sets the attribute id with the value... type="button" value="Get Attribute Node(Align)" onclick="getAttributeNodeAlign... JavaScript getAttributeNode method   
How to change the value of a variable which is set in jsp (by jstl method) by calling the function from js?
How to change the value of a variable which is set in jsp (by jstl method) by calling the function from js?  How to change the value of a variable... the value in jsp by using jstl method for eg:'<'c:set var="name1" value="Add User
Multiple Value initialization and retrieval by put and get method
that how firstly in program we putting the value of the preferences like int type ,Boolean type, and simple key value after that we are just using the get method... Multiple Value initialization and retrieval by put and get method
Method in Java
or a void. If the return type is void it means the method does not returns a value... topic Field. Return type: A return type defines the type of value returned from... (if the method does not return a value). If the method declares a return type
Given a particular method condition, identify the following: whether an exception will be thrown, the type of exception thrown, the container's action, and the client's view.
Given a particular method condition, identify the following: whether an exception will be thrown, the type of exception thrown...;Exceptions Next    Given a particular method condition
JavaScript getAttribute method
the functionality of this getAttribute() method. The flag value may be 0, 1.... is a global services company.</p>   <input type="button" value=" Get id " onclick="getID();">   <input type="button" value
Conversion from int to String
an int type value to a String type. You will convert an int value ... value from console and convert this int value to String type data. The line int... = Integer.toString(myint) converts myint int value to mystring String type data. Code
FTPClient : Get System Type
This section explain how to get system type by using method of FTPClient class in java
Java bigdecimal setScale example
is demonstrated. Method return type is a bigdecimal value therefore it generates only bigdecimal object values. The returned bigdecimal object value is numerically equal to the object value in which the method is invoked. In short
Get Ascii Value
Get Ascii Value       To print ascii value of a character this is the the simplest way to change the type a character. Here in the example given below we will select
method
method   how and where, we can define methods ? can u explain me with full programme and using comments
method
method  can you tell me how to write an abstract method called ucapan() for B2 class class A2{ void hello(){ system.out.println("hello from A2"); }} class B2 extends A2{ void hello(){ system.out.println("hello from B2
method - Java Beginners
the method must return a value that is assignable to a variable of the declared returned type. The getPermissions method could not return, say, a String, because...method  Method Sir, I am confusing in this sentence and did
JavaScript bold method
;mytext" type="text" value="" > <input type="... JavaScript bold method       One of the method defined in the string to show bold string
Java bigdecimal multiply method example
multiply method example. Method returns a bigdecimal object value. Method... are created and assigned integer as well double type values.  Method throws... Java bigdecimal multiply method example   
MySQL Boolean Value
MySQL Boolean Value       MySQl Boolean Value is used to display the Boolean type status of the field... 'MySQL Boolean Value'. To understand the example execute a query 'SHOW TABLE
Java BigInteger max value
these are equal, any of them may be returned. Syntax of max() method of BigInteger class... Java BigInteger max value       We can use the max() method of the BigInteger class to get
Java bigdecimal scaleByPowerOfTen example
method working is demonstrated. Method return type is a bigdecimal value therefore it generates only bigdecimal object values. The returned bigdecimal object value... to the power n. In short the returned value is equivalent to this * (Ten to the power n
JavaScript setDate method
JavaScript setDate method       JavaScript setDate() method can be used to set a date value to the date...() method to set current date with the value provided by the user into  date
Type conversion example
value, Class type) { // TODO Auto-generated method stub if(value==null...Type Conversion Example An example of type conversion is given below, which... on Submit button, Then the converted value display on the browser. At first make

Ads