Skip to main content

Please help with generic program. How to add the two integers in this program.

Please note these java.net forums are being decommissioned and use the new and improved forums at https://community.oracle.com/community/java.
1 reply [Last post]
samdaniel
Offline
Joined: 2013-08-06

/**
* @(#)demoGen.java
*
* @author Sam
* @version 1.00 2013/9/6
*/

public class demoGen {

public demoGen(T t1,T t2) {
System.out.println(t1+t2);
}

public static void main(String[] args) {

demoGen dem=new demoGen(10,15);
demoGen demo=new demoGen("sam is ","good");

}
}

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
ershadow786
Offline
Joined: 2013-07-10

i think there something wrong with your code you have not declared class T ..........and much more u are just making code complex like this..................