freepeople性欧美熟妇, 色戒完整版无删减158分钟hd, 无码精品国产vα在线观看DVD, 丰满少妇伦精品无码专区在线观看,艾栗栗与纹身男宾馆3p50分钟,国产AV片在线观看,黑人与美女高潮,18岁女RAPPERDISSSUBS,国产手机在机看影片

正文內(nèi)容

交通大學(xué)資訊工程學(xué)系-資料下載頁(yè)

2025-01-05 16:40本頁(yè)面
  

【正文】 f numbers, Strings, (and ―parable‖ Objects). Methods: int pos = (arr, target)。 (arr)。 (arr, from, to)。 (arr, value)。 // fills arr with a given value (arr, from, to, value)。 交通大學(xué)資訊工程學(xué)系 蔡文能 第 46頁(yè) Java More Java Examples (1/2) Benchmarks uses the class — a more controlled way to generate random numbers. Constructors: If we set the same ―seed,‖ we get the same ―random‖ sequence. Random generator = new Random( )。 Random generator2 = new Random(seed)。 Default “seed”: () long seed。 交通大學(xué)資訊工程學(xué)系 蔡文能 第 47頁(yè) Java More Java Examples (2/2) Methods: int k = ()。 int k = (n)。 double x = ()。 All 232 possible int values are produced with (approximately) equal probability 0 ? k n 0 ? x 1 交通大學(xué)資訊工程學(xué)系 蔡文能 第 48頁(yè) Java More Java Examples Interface The List library interface describes a list of objects in abstract terms In a list, objects are arranged in sequence obj0, obj1, ..., objn1 In Java, a list holds references to objects A list can contain duplicate objects (both (obj2) and obj1 == obj2 ) 交通大學(xué)資訊工程學(xué)系 蔡文能 第 49頁(yè) Java More Java Examples List Methods (a Subset) int size()。 boolean isEmpty ()。 boolean add (Object obj)。 void add (int i, Object obj)。 Object set(int i, Object obj)。 Object get(int i)。 Object remove(int i)。 boolean contains(Object obj)。 int indexOf(Object obj)。 returns true inserts obj as the ith value。 i must be from 0 to size() i must be from 0 to size() 1 use equals to pare objects 交通大學(xué)資訊工程學(xué)系 蔡文能 第 50頁(yè) Java More Java Examples (1/6) Implements List using an array Keeps track of the list capacity (the length of the allocated array) and list size (the number of elements currently in the list) Cat Hat Bat capacity size 交通大學(xué)資訊工程學(xué)系 蔡文能 第 51頁(yè) Java More Java Examples ArrayList (2/6) Automatically increases (doubles) the capacity when the list runs out of space。 allocates a bigger array and copies all the values into it get(i) and set(i, obj) are efficient because an array provides random access to its elements Throws IndexOutOfBoundsException when i 0 or i ? size() 交通大學(xué)資訊工程學(xué)系 蔡文能 第 52頁(yè) Java More Java Examples ArrayList (3/6) ArrayList holds objects (of any type) If you need to put ints or doubles into a list, use a standard Java array or convert them into Integer or Double objects You have to remember what types of objects your put into the list and may need to cast a retrieved object back into its type 交通大學(xué)資訊工程學(xué)系 蔡文能 第 53頁(yè) Java More Java Examples ArrayList (4/6) From Java API Docs: : ArrayList(Collection? extends E c) Constructs a list containing the elements of the specified collection, in the order they are returned by the collection39。s iterator. 交通大學(xué)資訊工程學(xué)系 蔡文能 第 54頁(yè) Java More Java Examples ArrayList list = new ArrayList ()。 (new Integer(1))。 (new Integer(2))。 (new Integer(3))。 int sum = 0。 for (int i = 0。 i ()。 i++) sum += ((Integer) (i)) . intValue()。 ArrayList (5/6) Example 1 Need a cast to Integer in order to call intValue 交通大學(xué)資訊工程學(xué)系 蔡文能 第 55頁(yè) Java More Java Examples ArrayList words = new ArrayList (4)。 (One)。 (Fish)。 (Two)。 (Fish)。 int i = 0。 while (i () ) { if ( ”Fish.equals ((i)) ) (i)。 else i++。 } ArrayList (6/6) Example 2 Shifts all the values after the ith to the left and decrements the size 交通大學(xué)資訊工程學(xué)系 蔡文能 第 56頁(yè) Java More Java Examples Generic type 交通大學(xué)資訊工程學(xué)系 蔡文能 第 57頁(yè) Java More Java Examples Generic Programming Define software ponents with type parameters ? A sorting algorithm has the same structure, regardless of the types being sorted ? Stack primitives have the same semantics, regardless of the ? objects stored on the stack. Compile time parameters Implementation ? Same code used for different parameter values ? Different code generated for different values C++ model: template class Java : type inference 交通大學(xué)資訊工程學(xué)系 蔡文能 第 58頁(yè) Java More Java Examples More examples, … 交通大學(xué)資訊工程學(xué)系 蔡文能 第 59頁(yè) Java More Java Examples 謝謝觀看 /歡迎下載 BY FAITH I MEAN A VISION OF GOOD ONE CHERISHES AND THE ENTHUSIASM THAT PUSHES ONE TO SEEK ITS FULFILLMENT REGARDLESS OF OBSTACLES. BY FAITH I BY FAITH
點(diǎn)擊復(fù)制文檔內(nèi)容
教學(xué)課件相關(guān)推薦
文庫(kù)吧 www.dybbs8.com
備案圖鄂ICP備17016276號(hào)-1