public static int hexToDecimal(String hex) {

int decimalValue = 0;
for (int i = 0; i < hex.length(); i++) {
decimalValue = decimalValue * 16 + hexCharToDecimal(hex.charAt(i));
}
return decimalValue;
}

public static int hexCharToDecimal(char ch) {

if (ch <= 'F' && ch >= 'A') {
return 10 + ch - 'A';
}
else {
return ch - '0';
}
}

System.out.println("The decimal number for hex " + hexString
+ " is " + hexToDecimal(hexString.toUpperCase()));

最新文章

  1. Mybatis关联查询和数据库不一致问题分析与解决
  2. UWP 判断windows mobile是使用的实体键还是虚拟按键
  3. 简述cookie
  4. .NET面试题解析(00)-开篇来谈谈面试 &amp; 系列文章索引
  5. Hyperledger智能合约Hello World示例程序
  6. APP UI设计相关的一些链接
  7. umbraco使用VS安装
  8. MessageBox.Show()如何换行
  9. bzoj2466: [中山市选2009]树
  10. vs2012+cmake+opencv+opencv unable to find a build program corresponding to &quot;Visual Studio 12 Win64&quot;. CMAKE_MAKE_PROGRAM is not set
  11. iOS Runtime 实践(1)
  12. 关于Daydream VR的最直白的介绍
  13. codeforces 616E. Sum of Remainders 数学
  14. IOS9.0 之后友盟分享详细过程
  15. /etc/fstab 文件挂载配置文件
  16. EZ 2018 06 02 NOIP2018 模拟赛(十七)
  17. 自动化脚本编写环境部署_win7(RF)
  18. XMLHttpRequest 的使用&amp;#183;&amp;#183;&amp;#183;&amp;#183;&amp;#183;&amp;#183;
  19. 6. 集成学习(Ensemble Learning)算法比较
  20. 前端基础进阶之Promise

热门文章

  1. ORA-00214: control file 控制文件版本不一致
  2. c++ 读取并解析excel文件方法
  3. 五指CMS发布,主打高性能
  4. 《Android View 的事件分发和滑动冲突》 —预习资料
  5. Kafka系列(一)安装和配置说明
  6. Xcode部分插件无法使用识别的问题
  7. Java和.NET的GZIP压缩功能对比
  8. 为Android安装BusyBox
  9. 解决libpython2.6.so.1.0: cannot open shared object file
  10. 用document.title=“xxx”动态修改title,在ios的微信下面不生效