method « cast « Java Data Type Q&A





1. question about virtual methods in java    stackoverflow.com

Put simply: I want the following code to print "sub":

Element e = new SubElement();
print(e);
... 

private static void print(Element e) {
    System.out.println("e");
}

private static void print(SubElement e) {
   ...

2. Java Rectangles and Casting    stackoverflow.com

Obviously based on the class assignment this is homework..so help me as much as you can/want, don't flame me for posting HW okay? I have been dying, reading through my book, reading ...

3. Can you cast a method argument?    coderanch.com

I have a method: public static void methodName( long x , int y ) If I want to use this method but some of my y's are longs, can i do this in those cases: methodName( sampleInteger , ( int )( sampleLong ) ); I got a compile error but I'm wondering if there is another way to do this. If ...

5. casting the return value from method.invoke()    coderanch.com

I have a method that is working fine. But the handling of return values from method.invoke() seems kinda funky. The method.invoke() call is in a loop that processes a bunch of files, the names of which are provided by the cmm.filename variable. All of the file handling functions return boolean (whether processing was successful or not). So, As you can see ...

8. Casting (artist needed) method params    forums.oracle.com

Method signatures are selected at compile time, not run time. Since the variable is declared as Object, that's what's used to bind the call to a method, at compile time it's not known that the actual object will be of class Artist. Run time binding, while theoretically possible, would be unacceptably slow (requiring a search of the methods list for every ...