Privacy Policy Terms Of Use. Copyright © 2006-2010 Java Tutorials and Examples.
Oracle and Java are registered trademarks of Oracle and/or its affiliates. Other names may be trademarks of their respective owners.
- /*
- * Convert String to Short example. Program to convert Java
- * String object to Short object.
- */
- public class StringToShort {
- public static void main(String args[]){
- //new String object
- String str = new String("32");
- //Use Short(String) constructor
- Short sObj1 = new Short(str);
- //OR Use static valueOf(String) method of Short class
- Short sObj2 = Short.valueOf(str);
- System.out.println("String converted to Short: " + sObj1);
- }
- }

Post new comment