Convert String to Short - Java Language Basics

Java examples for Language Basics:short

Description

Convert String to Short

Demo Code

 
public class Main {
 
  public static void main(String[] args) {
   //from   ww w .  jav a2s  .  c o  m
    Short sObj1 = new Short("100");
    System.out.println(sObj1);
   
    String str = "100";
    Short sObj2 = Short.valueOf(str);
    System.out.println(sObj2);
   
  }
}

Result


Related Tutorials