package com.bmc.sandbox;
import org.apache.poi.util.SystemOutLogger;
public class Snadbox {
String name;
static String address;
static Integer num1 = 100;
static Integer num2 = 200;
static String str1 = "Apple";
static String str2 = "Orange";
public static void main(String[] args) {
TestThis test = new TestThis();
System.out.println(test);
test.a();
// creating an Integer object
NonGeneric nongeneric1 = new NonGeneric(num1, num2);
System.out.println(nongeneric1.getObj1());
System.out.println(nongeneric1.getObj2());
// creating a string object
NonGeneric nongeneric2 = new NonGeneric(str1, str2);
System.out.println(nongeneric2.getObj1());
System.out.println(nongeneric2.getObj2());
}
}
class NonGeneric {
Object obj1;
Object obj2;
public NonGeneric() {
// TODO Auto-generated constructor stub
}
public NonGeneric(Object obj1, Object obj2) {
// TODO Auto-generated constructor stub
this.obj1 = obj1;
this.obj2 = obj2;
}
public Object getObj1() {
return obj1;
}
public Object getObj2() {
return obj2;
}
}
class TestThis {
public void a() {
System.out.println(this);
}
}
Sunday, January 24, 2016
Java Object equivalent to Generics
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment