Java tutorial
//package com.java2s; public class Main { public static final Object getObjectValue(String value) { try { return Long.valueOf(value); } catch (NumberFormatException e) { } try { return Double.valueOf(value); } catch (NumberFormatException e) { e.printStackTrace(); return value; } } }