狸猫的笔试——字符转int
来源:互联网 发布:链轮链条设计软件 编辑:程序博客网 时间:2024/04/28 01:01
public static int getInt(String s,int radix) throws Exception{if(s == null || "".equals(s)||radix > 10||radix < 1){throw new Exception("input error");}int len = s.length();char firstChar = s.charAt(0);boolean flag = false;int result = 0;int i = 0;if(firstChar < '0'){if(len == 1){throw new Exception("input error");}if(firstChar == '-'){flag = true;limit = -Integer.MAX_VALUE;}else if( firstChar != '+'){throw new Exception("s is not number");}i++;}while(i < len){if(s.charAt(i) < '0' || s.charAt(i) > '9'){throw new Exception("s is not number");}result = result * radix + (s.charAt(i++) - '0');}return flag?-result:result;}
0 0
- 狸猫的笔试——字符转int
- 狸猫的笔试——蛇形矩阵
- 狸猫的笔试——格雷码判断
- 狸猫的笔试——查找
- 狸猫的笔试——集合
- 狸猫的笔试——n位格雷码的生成
- 狸猫的笔试——镜像字符串(二叉树法)
- 狸猫的面试——链表
- 狸猫的面试——JVM综述
- 狸猫的面试——JVM内存回收
- 狸猫的面试——项目描述——矢量裁剪
- 狸猫的面试——项目描述——视频通信
- Python mock测试static 方法——狸猫换太子
- Maven2上演狸猫换太子――字符编码造成的诡异故障
- 字符char转整形int的操作方法
- 字符转int
- int 单个字符转
- Int转byte类型转换的笔试题
- Web端服务器推送技术原理分析及dwr框架简单的使用
- 13_动态代理和静态代理的区别
- 14_java中的设计模式
- 如何阅读一本书(3)
- 用struts1进行文件的下载
- 狸猫的笔试——字符转int
- LeetCode 93. Restore IP Addresses
- 15_工厂设计模式
- 微信开发模式之自定义菜单实现
- android学习——handler的学习及实现封装下载图片功能
- 虚拟机技术
- C++ 中Traits技术 (2) —— 与迭代器
- 16_获取联系人信息
- 【BZOJ1005】明明的烦恼