会挽雕弓如满月,西北望,射天狼。 注册 | 登陆
浏览模式: 标准 | 列表分类:越飞越高

Java学习日记:正则表达式

很早就看到正则表达式了,但是一直没有机会学,这回Java也有正则表达式的API,正好可以学一学。
正则表达式验证字符串的合法性的效率真是那个高啊,呵呵。
通过学习,参考了网上的一些做法,写出了一个自己认为比较完美的email正则表达式(写为一行):

^[a-zA-Z0-9]+((\.|_|-)[a-zA-Z0-9]+)*@
[a-zA-Z0-9]+((\.|-)[a-zA-Z0-9]+)*\.[a-zA-Z]{2,4}$

» 阅读全文

Tags: 编程, Java

Java学习日记:Annotations & Generics

这两个内容虽然不是十分的重要,但确是Java的特性,以后再找相关书籍来看看。
引用内容 引用内容
Annotations provide data about a program that is not part of
 the program itself. They have no direct effect on the operation of the 
code they annotate. 
Annotations have a number of uses, among them: 

» 阅读全文

Java学习日记:枚举类型功能的扩大

Java赋予了enum强大的力量,把他当一个类来使用了,可以添加方法和构造函数等等强大的功能。
引用内容 引用内容
Java programming language enum types are much more
 powerful than their counterparts in other languages. The enum 
declaration defines a class (called an enum type). The enum class
 body can include methods and other fields. The compiler automatically 
adds some special methods when it creates an enum. For example, 

» 阅读全文

Tags: 编程, Java

Java学习日记:for循环的新用法

Java为其for循环实现了针对数组和集合类的新用法:
引用内容 引用内容
The for statement also has another form designed 
for iteration through Collections and arrays This form is 
sometimes referred to as the enhanced for statement, 
and can be used to make your loops more compact and 
easy to read. To demonstrate, consider the following array,

» 阅读全文

Tags: 编程, Java

Java学习日记:新运算符 >>>

  为了达到与平台无关,Java增加了一种位运算符“>>>”,相对于C/C++的“>>”的右移是否带符号与机器平台有关,而Java是与平台无关,所以为了解决这个问题,引入“>>>”
引用内容 引用内容
The signed left shift operator "<<" shifts a bit pattern to the left, 
and the signed right shift operator ">>" shifts a bit pattern to the right. 
The bit pattern is given by the left-hand operand, and the number of 
positions to shift by the right-hand operand. The unsigned right shift 
operator ">>>" shifts a zero into the leftmost position, while the leftmost

» 阅读全文

Tags: 编程, Java

Records:231234