7:08 am - Thursday December 13, 2018

Short Example Program for parseShort(String s,int radix)

Corporate Training for Experienced Candidate
Struts | Hibernate | Spring | Java / J2EE
SOAP | RestFull | Design Pattern | more...
Ph: +91 72000 69003
137b, 2nd st, shanthi nagar, Chrompet, Chennai -600044
*@author :CandidJava.com
*@descriptions : This program explains how the first string argument converted as a signed short in the radix specified by the second argument.
public class ParseShort
public static void main(String ar[]) throws Exception
String s1="64";     //Input value as string
short o=Short.parseShort(s1,8);  //Given string argument converted in to short octal value.
short d=Short.parseShort(s1,10); //Given string argument converted in to short Decimal value.
short hd=Short.parseShort(s1,16);  //Given string argument converted in to short HexaDecimal 	value.
System.out.println("Octal Value:"+o);
System.out.println("decimal Value:"+d);
System.out.println("hexadecimal Value:"+hd);

octal value: 52
Decimal value: 64
Hexa Decimal value: 100


Filed in: Z-A All Java Codes

Comments are closed.