Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa Java-Beginners Type casting the returned value of a method.
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


Justin Calleja
Type casting the returned value of a method.
2 Answer(s)      4 years and a month ago
Posted in : Java Beginners


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


Advertisement
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... know that the component returned by panel.getComponent(i) will be of type
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){ try{ Query q...){ return null; } how to type cast object type to entity type
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
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
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 casting?
What is casting?   Hi, What is casting? thanks
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
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
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
PHP Type Juggling
a float value to a variable then it becomes float type and if we assign...;Value of temp is:".$temp." and data type is: ".gettype($temp... "Value of temp is:".$temp." and data type is: ".gettype
Java BigDecimal floatValue method example
translates bigdecimal value in to float type value. Method throws ..., original bigdecimal value is also shown.  Syntax for using the method: public... Java BigDecimal floatValue method example  
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
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
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
Data Provider or other service returned an E_FAIL status Error
Data Provider or other service returned an E_FAIL status Error... and got the error "Data Provider or other service returned an E_FAIL status... that there was a datetime field in the database whose default value was "
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
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
Get Ascii Value
that will be their ascii value. Method charAt() of String class is used to select... Get Ascii Value       To print ascii value of a character this is the the simplest way
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
 

 

 

DMCA.com