1. Trang chủ
  2. » Mẫu Slide

Session5 module6 7 generic regularexpression

33 637 0

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 33
Dung lượng 769,39 KB

Nội dung

m mới bắt đầu học java nên chưa có kinh nghiệm gì, nên mong các tiền bối đi trước cho em vài lời khuyên. trước đây em có học qua về c++ với C và php nhưng không thực sự giỏi cái nào. hiện nay em đang có bài tập lớn về java,mà em thì không có kinh nghiệm gì về nó nên muốn chọn mảng nào dễ hơn để có thể dễ bắt đầu, nếu các anh chị nào đã học qua thì cho em 1 vài lời khuyên với.em xin cám ơn các anh chị trước.

    • !" • List#!$! "!!ArrayList LinkedList • Set!"!! HashSetLinkedSetLinkHashSet" • Queue%%&"&'!!PriorityQueue" • Iterator!## #( " • )Map'Entry"#*' keyvalue"' #+* ",* $" • Arrays' + #*" &'#!" Advanced Java / Session3 / 2 of 33 - A Guide To Advanced Java – Module 6 .&$/ Advanced Java / Session3 / 3 of 33 A Guide To Advanced Java – Module 6 Generic “I’d like a Cup of T” Advanced Java / Session3 / 4 of 33 A Guide To Advanced Java – Module 6 * • * *$* ##!!'*#*'$/ # + #!! !!" •  #!!!!#*' !#$#+" Advanced Java / Session5 / 5 of 29  )0)  Advanced Java / Session1 / 6 of 13 List list = new ArrayList(); Integer numberInt = new Integer(9); list.add(numberInt); Integer n=(Integer) list.get(0); System.out.println(list);  Before generics, you would write this piece of code:  With generics, this code becomes: List<Number> list = new ArrayList<Number>(); Number numberInt = new Integer(9); list.add(numberInt); Integer n= list.get(0); System.out.println(list); )1!' •  exibility' *!$" • *##! check for type correctness '#!at the compile time. • #! are less time consuming to #x #!" • 0# ! the ambiguity is less $ " • lesser casts##! $*$" • *cannot create generic constructors. • )$$  ##+* *2'! ##" Advantages Limitations Advanced Java / Session3 / 7 of 33 A Guide To Advanced Java – Module 6  • )!#!'*#*#$  !*$/* • *' class ClassName <T> {} • *'# ClassName<specific datatype> obj = new ClassName<specific datatype>(); Advanced Java / Session3 / 8 of 33 A Guide To Advanced Java – Module 6 !# Advanced Java / Session3 / 9 of 33 A Guide To Advanced Java – Module 6 34 # There are three types of wildcards used with generics. Advanced Java / Session3 / 10 of 33 A Guide To Advanced Java – Module 6 [...]... limitations of generics Explain what is meant by a generic class Explain how to declare and instantiate a generic class Define generic methods Describe how to declare a generic method Advanced Java / Session5 / 15 of 29 A Guide To Advanced Java – Module 6 15 Module 7: Objectives Advanced Java / Session5 / 16 of 33 A Guide To Advanced Java – Module 7 16 Regular Expression Writing a regular expression... Module 6 Using Legacy Code in Generics • In Java, genericity ensures that the same class file is generated by both legacy and generic version with some additional information about types • In generic code, the classes are accompanied by a type parameter When a generic type like collection is used without a type parameter, it is called a raw type • Erasure removes all generic type information All the... Advanced Java / Session5 / 17 of 33 A Guide To Advanced Java – Module 7 17 What is RegEx?   Regular expressions(RegEx) help describing a pattern of text  They are used to search, edit and manipulate text based on patterns RegEx is a set of symbols and syntactic elements which are used to match patterns in a text Advanced Java / Session5 / 18 of 33 A Guide To Advanced Java – Module 7 18 Regular Expression... Module 6 Using Generics in Legacy Code • • A generic library should be created when there is access to source code Update the entire library source as well as the client code to eliminate potential unchecked warning Advanced Java / Session5 / 14 of 29 A Guide To Advanced Java – Module 6 14 Module Review • • • • • • Identify the need for generics List the advantages and limitations of generics Explain... Result: Found “pa” in group(1) Advanced Java / Session5 / 29 of 33 A Guide To Advanced Java – Module 7 29 Module Review • In this workshop, you learnt to: – Use character classes and techniques for regular expressions – Use boundary matchers – Use quantifiers Advanced Java / Session5 / 30 of 33 A Guide To Advanced Java – Module 7 30 Q&A A Guide to Advanced Java GENERIC/ RegEX Advanced Java / Session1 / 31... "xxxxxxfoo" starting at index 4 and ending at index 13 Enter your regex: *+foo // possessive quantifier Enter input string to search: xfooxxxxxxfoo No match found Advanced Java / Session5 / 27 of 33 A Guide To Advanced Java – Module 7 27 Capturing Groups • In capturing group, multiple characters are treated as a single unit, which are placed inside single parentheses • Captured groups are numbered by counting... while (m.find()) { System.out.println(m.group()); } Advanced Java / Session5 / 19 of 33 A Guide To Advanced Java – Module 7 19 Regular Expression Pattern Syntax • • • • • • String Literals Character classes Quantifiers Capturing Groups Boundary Matchers Back references Advanced Java / Session5 / 20 of 33 A Guide To Advanced Java – Module 7 20 String Literals • • Literal is a constant value used to initialize... Advanced Java – Module 7 23 Boundary Matchers  Boundary Matchers  ^  The beginning of a line  $  The end of a line  \b  A word boundary  \B  A non-word boundary  \A  The beginning of the input  \G  The end of the previous match  \Z  The end of the input but for the final terminator, if any  \z  The end of the input Advanced Java / Session5 / 24 of 33 A Guide To Advanced Java – Module 7 24 Quantifiers •...Exception Handling with Generics Click to edit Master text styles Second level Third level Fourth level Fifth level Advanced Java / Session3 / 11 of 33 Session5 29 A A GuideTo AdvancedJava – Module 6 6 Guide To Advanced Java – Module 11 Inheritance with Generics Click to edit Master text styles Second level Third level Fourth level Fifth... Advanced Java / Session5 / 22 of 33 A Guide To Advanced Java – Module 7 22 Predefined Character Classes Predefined Character Classes Any character (may or may not match line terminators) \d A digit: [0-9] \D A non-digit: [^0-9] \s A whitespace character: [ \t\n\x0B\f\r] \S A non-whitespace character: [^\s] \w A word character: [a-zA-Z_0-9] \W A non-word character: [^\w] Advanced Java / Session5 / 23 . Integer n=(Integer) list.get(0); System.out.println(list);  Before generics, you would write this piece of code:  With generics, this code becomes: List<Number> list = new ArrayList<Number>();. three types of wildcards used with generics. Advanced Java / Session3 / 10 of 33 A Guide To Advanced Java – Module 6 5 # Advanced Java / Session5 / 11 of 29 66 )0) Click. !#" Advanced Java / Session5 / 15 of 29 6 )0) .&$/ Advanced Java / Session5 / 16 of 33 6 )0) Regular

Ngày đăng: 22/11/2014, 16:39

TỪ KHÓA LIÊN QUAN

TÀI LIỆU CÙNG NGƯỜI DÙNG

  • Đang cập nhật ...

TÀI LIỆU LIÊN QUAN

w