Results 1 to 2 of 2
Thread: covariant return types
- 04-19-2010, 08:02 AM #1
Member
- Join Date
- Apr 2010
- Posts
- 1
- Rep Power
- 0
covariant return types
hi,I am new to java...
I couldn't learn about covariant return types in java..
who can explain me...
my other question is
class A{
public A go(){
return new A();
}
public static void main(String args[]){
A n=new A();
n.go();//what will occur,I dont know how metod works with class
//name,plz help
}
}
- 04-19-2010, 09:16 AM #2
Senior Member
- Join Date
- Mar 2010
- Posts
- 953
- Rep Power
- 4
Please use CODE tags when posting code.
This article (first Google hit for "Java covariant return types") explains it pretty well. Tell us what you don't understand about it.
Java Tips - Covariant return types
Essentially nothing will happen. You are creating one new object of type A, then calling its go() method, which creates another new object of type A. But you are not doing anything with the second one, and not even assigning it to a variable. Objects of type A have no local storage, or any other significant side effects, so basically nothing happens.
-Gary-
Similar Threads
-
> Operator cannot be applied error and return incompatible types error
By corney_16 in forum New To JavaReplies: 1Last Post: 03-10-2010, 01:53 PM -
Help with sorting two types:
By twcast in forum New To JavaReplies: 2Last Post: 02-11-2010, 04:37 PM -
Java Native Access (JNA) return types of void *
By burnumd in forum Advanced JavaReplies: 5Last Post: 01-15-2010, 12:09 AM -
generic types
By jon80 in forum New To JavaReplies: 6Last Post: 06-12-2009, 10:29 PM -
Collection Types
By DavidG24 in forum New To JavaReplies: 2Last Post: 04-18-2009, 05:03 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks