sjain1203
asked on
converting string to short in java
this is what i have done:
public static void main (String[] args) throws IOException {
short s= 0;
String g = "1test";
try {
s = Short.parseShort(g);
//s = (short)Integer.parseInt(g. trim(), 16);
System.out.println(s);
} catch (NumberFormatException e){}
System.out.println("except ion");
}
I need to print the value of s.
Thanks in advance,
Sid
public static void main (String[] args) throws IOException {
short s= 0;
String g = "1test";
try {
s = Short.parseShort(g);
//s = (short)Integer.parseInt(g.
System.out.println(s);
} catch (NumberFormatException e){}
System.out.println("except
}
I need to print the value of s.
Thanks in advance,
Sid
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
String str;
str=g.subString(0,1);
short val = Convert.stringToShort (digitString, (short) defaultValue);
if u want detail of above Convert u can refer
http://www.cems.uwe.ac.uk/~lrlang/java_html/docs/uwejava/Convert.html
str=g.subString(0,1);
short val = Convert.stringToShort (digitString, (short) defaultValue);
if u want detail of above Convert u can refer
http://www.cems.uwe.ac.uk/~lrlang/java_html/docs/uwejava/Convert.html
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
--Sid