Java examples for java.lang:String Parse
Parse Short from String with default value
//package com.java2s; public class Main { public static void main(String[] argv) throws Exception { String value = "java2s.com"; System.out.println(getShort(value)); }//from w w w . j a v a2 s.c om public static Short getShort(String value, Short defaultValue) { try { return Short.valueOf(value); } catch (Exception ex) { return defaultValue; } } public static Short getShort(String value) { return getShort(value, null); } }