From 43fcd4a31c0612b4134bc816e5284c4f904cf0d5 Mon Sep 17 00:00:00 2001 From: Doni Pracner Date: Wed, 29 Apr 2015 13:26:15 +0200 Subject: [PATCH] Jednostavan primer za opsti tip (generic) u programskom jeziku Java --- kodovi/skup/OpstiTipoviPrimeri.java | 32 +++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 kodovi/skup/OpstiTipoviPrimeri.java diff --git a/kodovi/skup/OpstiTipoviPrimeri.java b/kodovi/skup/OpstiTipoviPrimeri.java new file mode 100644 index 0000000..26e96d3 --- /dev/null +++ b/kodovi/skup/OpstiTipoviPrimeri.java @@ -0,0 +1,32 @@ +class Cuvar { + 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 st = new Cuvar(); + st.info = "neki string"; + System.out.println(st); + + Cuvar broj = new Cuvar(); + broj.info = 5; + System.out.println(broj); + + Cuvar realan = new Cuvar(5.0); + System.out.println(realan); + } +} -- 2.25.1