gitweb on Svarog

projekti pod git sistemom za održavanje verzija -- projects under the git version control system
Jednostavan primer za opsti tip (generic) u programskom jeziku Java
authorDoni Pracner <quinnuendo@gmail.com>
Wed, 29 Apr 2015 11:26:15 +0000 (13:26 +0200)
committerDoni Pracner <quinnuendo@gmail.com>
Wed, 29 Apr 2015 11:26:15 +0000 (13:26 +0200)
kodovi/skup/OpstiTipoviPrimeri.java [new file with mode: 0644]

diff --git a/kodovi/skup/OpstiTipoviPrimeri.java b/kodovi/skup/OpstiTipoviPrimeri.java
new file mode 100644 (file)
index 0000000..26e96d3
--- /dev/null
@@ -0,0 +1,32 @@
+class Cuvar<T> {
+       T info;
+       
+       public String toString(){
+               return "Cuvam:" + info;
+       }
+       
+       public Cuvar(){
+               info = null;
+       }
+       
+       public Cuvar(T podatak){
+               this.info = podatak;
+       }
+}
+
+
+public class OpstiTipoviPrimeri {
+
+       public static void main(String[] args) {
+               Cuvar<String> st = new Cuvar<String>();
+               st.info = "neki string";
+               System.out.println(st);
+               
+               Cuvar<Integer> broj = new Cuvar<Integer>();
+               broj.info = 5;
+               System.out.println(broj);
+               
+               Cuvar<Double> realan = new Cuvar<Double>(5.0);
+               System.out.println(realan);
+       }
+}
Svarog.pmf.uns.ac.rs/gitweb maintanance Doni Pracner