package com.example.generic;

import java.util.ArrayList;
import java.util.List;

public class GenericExample {

	public static void main(String[] args) {

		// non-generic list
		List list = new ArrayList();
		
		// add anything to list
		list.add("hello");
		list.add(true);
		list.add(123);
		
		// retrieval with non-generic is tedious
		// 1. check the actual datatype
		// 2. casting/convert
		// 3. access the value
		for (Object o : list) {
			if (o instanceof String) {
				System.out.println("this is a string value: " + o);
			}else if(o instanceof Integer) {
				int i = Integer.parseInt(o);
			}
		}
	}

}
