8:54 am - Friday May 25, 2018

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

CANDID INDUSTRIAL TRAINING -- CHENNAI
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
@description: valueOf(String s,int radix) this method is used to a Short object holding the value represented by the string argument in the specified radix.
*/
public class ShortValueOf extends Dee
{
public static void main(String []args)
{
try{
String s="234";//initialize and declare the s value
int radix=16;//initialize and declare the radix value
Integer i=Integer.valueOf(s,radix);// a Short object holding the value represented by the string argument //in the specified radix.
System.out.println(i);//to print the value i
}
catch(NumberFormatException nfe)//if the exception found mean catch this block
{
System.out.println(nfe.getMessage());//to print the exception massage
}
}
}
class Dee //sub class
{
Dee(){}
void Dee() throws NumberFormatException
{}
}

output

564

BACK

Filed in: Z-A All Java Codes

Comments are closed.