代码如下:
package heimait;
public class 字符串变为数字返回2个数字乘积
{
public static void main(String[] args)
{
String a = "1234";
String b = "123";
int c,d;
c = toNumber(a);
d = toNumber(b);
String r = (c * d) + "";
System.out.println(r);
}
public static int toNumber(String a)
{
int c = 0;
int x = 1;
for (int i = a.length() - 1; i >= 0 ; i--)
{
c = (a.charAt(i) - '0') * x + c ;
x = x * 10;
}
return c;
}
}
运行结果: