先定义一个枚举类型 , 初中, 高中,大学 }; int ->enum int d=2; PropertyType a=(PropertyType)d; int <- enum PropertyType d = PropertyType.小学; int a = Convert.ToInt32(d); Enum类有关的方法 Enum.Parse 方法 (Type, String) 将一个或多个枚举常数的名称或数字值的字符串表示转换成等效的枚举对象. public static Object
http://hongmin118.iteye.com/blog/2029728 转的 MySQL 的CAST()和CONVERT()函数可用来获取一个类型的值,并产生另一个类型的值.两者具体的语法如下: CAST(value as type); CONVERT(value, type); 就是CAST(xxx AS 类型), CONVERT(xxx,类型). mysql> SELECT CAST('3.35' AS signed); +------------------------+ |
今天鹅厂店面,最后问了一个ip地址字符串和整数间无损转化的问题,晚上有时间了手撸了一下代码. public class IPstr { public static void main(String args[]){ ipstrToint sti=new ipstrToint(); int ip=0; ip=sti.strToint("127.11.22.33"); if(ip==0) System.out.println("无效IP"); else System.o
public static int parseInt(String s, int radix) throws NumberFormatException{ /* * WARNING: This method may be invoked early during VM initialization * before IntegerCache is initialized. Care must be taken to not use * the valueOf method. */ if (s =