这里面包含了一百多个JAVA源文件

源代码在线查看: e362. finding an element in a sorted list.txt

软件大小: 551 K
上传用户: maple_78
关键词: JAVA
下载地址: 免注册下载 普通下载 VIP

相关代码

				// Create a list with an ordered list of strings
				    List sortedList = new LinkedList();
				    sortedList.addAll(Arrays.asList(new String[]{"ant", "bat", "cat", "dog"}));
				    
				    // Search for the word "cat"
				    int index = Collections.binarySearch(sortedList, "cat");    // 2
				    
				    // Search for a non-existent element
				    index = Collections.binarySearch(sortedList, "cow");        // -4
				
				A negative return value indicates that the element is not in the list. However, the actual return value can be used to determine where that non-existent element should be inserted in the list if that were desired; see e363 Inserting an Element into a Sorted List. 
				 Related Examples 
				
							

相关资源