Author: echatellier Date: 2010-02-03 17:12:48 +0100 (Wed, 03 Feb 2010) New Revision: 368 Added: misctestproject/trunk/src/main/java/org/nuiton/test/Generics.java Log: Test erreur generique Added: misctestproject/trunk/src/main/java/org/nuiton/test/Generics.java =================================================================== --- misctestproject/trunk/src/main/java/org/nuiton/test/Generics.java (rev 0) +++ misctestproject/trunk/src/main/java/org/nuiton/test/Generics.java 2010-02-03 16:12:48 UTC (rev 368) @@ -0,0 +1,54 @@ +/* *##% + * Copyright (C) 2010 Code Lutin, Chatellier Eric + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + *##%*/ + +package org.nuiton.test; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; + +class Factor<E, F> { + +} + +class FactorGroup<E, F> extends Factor<E, F> { + + Collection<Factor<E, F>> factors; + + public void addFactor(Factor<E, F> f) { + factors.add(f); + } +} + +public class Generics { + + public static void main(String args[]) { + Factor<Integer, Integer> factor1 = new Factor<Integer, Integer>(); + Factor<String, String> factor2 = new Factor<String, String>(); + + FactorGroup<Object,Object> factorGroup = new FactorGroup<Object, Object>(); + factorGroup.addFactor(factor1); // erreur + factorGroup.addFactor(factor2); // erreur + } + + public void testList() { + List<Object> list = new ArrayList<Object>(); + list.add(new Integer(0)); // OK + list.add(new String()); // OK + } +} Property changes on: misctestproject/trunk/src/main/java/org/nuiton/test/Generics.java ___________________________________________________________________ Added: svn:keywords + "Author Date Id Revision HeadURL"
participants (1)
-
echatellier@users.nuiton.org