C++ Builder 中怎么使用Hash_map,hash_set

wirner 2013-05-02 07:22:46

#include <hash_map>
#include <map>
#include <vector>
#include <Generics.collections.hpp>
#include <iostream>

hash_map<const char*, int, hash<const char*>, eqstr> months;

months["january"] = 31;
months["february"] = 28;
months["march"] = 31;
months["april"] = 30;
months["may"] = 31;
months["june"] = 30;
months["july"] = 31;
months["august"] = 31;
months["september"] = 30;
months["october"] = 31;
months["november"] = 30;
months["december"] = 31;


编译报错 hash_map报错。
...全文
183 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
我不懂电脑 2013-05-03
  • 打赏
  • 举报
回复
没有加名字空间 using namespace std;
sololie 2013-05-02
  • 打赏
  • 举报
回复
在help中一搜THashedStringlist不就马上有结果了嘛 inifiles.hpp
wirner 2013-05-02
  • 打赏
  • 举报
回复
Dephi中有THashedStringlist类,BCB中,能用吗? 在那个头文件中? 我想在BCB中建立一个Hash表。
庖丁解牛(侯捷自序) i 目录 v 前言 xvii 本书定位 xvii 合适的读者 xviii 最佳阅读方式 xviii 我所选择的剖析对象 xix 各章主题 xx 编译工具 xx 英术语的运用风格 xxi 英文术语采用原则 xxii 版面字形风格 xxiii 源码形式与下载 xxiv 在线服务 xxvi 推荐读物 xxvi 第1章 stl 概论与版本简介001 1.1 stl 概论 001 1.1.1 stl的历史 003 1.1.2 stl与c++ 标准程序库 003 . 1.2 stl 六大组件 - 功能与运用 004 1.3 gnu源码开放精神 007 1.4 hp stl实现版本 009 1.5 p.j. plauger stl实现版本 010 1.6 rouge wave stl实现版本 011 1.7 stlport 实现版本 012 1.8 sgi stl实现版本 总览 013 1.8.1 gnu c++ header 文件分布 014 1.8.2 sgi stl 文件分布与简介 016 stl 标准头文件(无扩展名) 017 c++ 标准规格定案前,hp规范的stl头文件(扩展名 .h) 017 sgi stl 内部文件(sgi stl真正实现于此) 018 1.8.3 sgi stl 的组态设定(configuration) 019 1.9可能令你困惑的c++ 语法 026 1.9.1 stl_config.h 的各种组态 027 组态3:static template member 027 组态5:class template partial specialization 028 组态6:function template partial order 028 组态7:explicit function template arguments 029 组态8:member templates 029 组态10:default template argument depend on previous template parameters 030 组态11:non-type template parameters 031 组态:bound friend template function 032 组态:class template explicit specialization 034 1.9.2 临时对象的产生与运用 036 1.9.3 静态常数整数成员在class 内部直接初始化 037 in-class static const integral data member initialization 1.9.4 increment/decrement/dereference 运算子 037 1.9.5 "前闭后开"区间表示法 [ ) 039 1.9.6 function call运算子(operator()) 040 第2章 空间配置器(allocator) 043 2.1 空间配置器的标准接口 043 2.1.1 设计一个简单的空间配置器,jj::allocator 044 2.2 具备次配置力(sub-allocation)的sgi 空间配置器 047 2.2.1 sgi 标准的空间配置器,std::allocator 047 2.2.2 sgi 特殊的空间配置器,std::alloc 049 2.2.3 构造和析构基本工具:construct() 和 destroy() 051 2.2.4 空间的配置与释放,std::alloc 053 2.2.5 第一级配置器 __malloc_alloc_template 剖析 056 2.2.6 第二级配置器 __default_alloc_template剖析 059 2.2.7 空间配置函数allocate() 062 2.2.8 空间释放函数deallocate() 064 2.2.9 重新充填free-lists 065 2.2.10 内存池(memory pool) 066 2.3 内存基本处理工具 070 2.3.1 uninitialized_copy 070 2.3.2 uninitialized_fill 071 2.3.3 uninitialized_fill_n 071 第3章 迭代器(iterators)概念与 traits 编程技法 079 3.1 迭代器设计思维 - stl关键所在 079 3.2 迭代器是一种 smart pointer 080 3.3 迭代器相应型别(associated types) 084 3.4 traits 编程技法 - stl源码门钥 085 partial specialzation(偏特化)的意义 086 3.4.1 迭代器相应型别之一value_type 090 3.4.2 迭代器相应型别之二difference_type 090 3.4.3 迭代器相应型别之三pointer_type 091 3.4.4 迭代器相应型别之四reference_type 091 3.4.5 迭代器相应型别之五iterator_category 092 以advanced() 为例 093 消除 "单纯传递调用函数" 097 以distance() 为例 098 3.5 std::iterator class 的保证 099 3.6 iterator相关源码完整重列 101 3.7 sgi stl的私房菜:__type_traits 103 第4章 序列式容器(sequence containers) 113 4.1 容器概观与分类 113 4.1.1 序列式容器(sequence containers) 114 4.2 vector 115 4.2.1 vector 概述 115 4.2.2 vector 定义摘要 115 4.2.3 vector 的迭代器 117 4.2.4 vector 的数据结构 118 4.2.5 vector 的构造与内存管理:constructor, push_back 119 4.2.6 vector 的元素操作:pop_back, erase, clear, insert 123 4.3 list 128 4.3.1 list 概述 128 4.3.2 list 的节点(node) 129 4.3.3 list 的迭代器 129 4.3.4 list 的数据结构 131 4.3.5 list 的构造与内存管理:constructor, push_back, insert 132 4.3.6 list 的元素操作:push_front, push_back, erase, pop_front, 136 pop_back, clear, remove, unique, splice, merge, reverse, sort 4.4 deque 143 4.4.1 deque 概述 143 4.4.2 deque 的控器 144 4.4.3 deque 的迭代器 146 4.4.4 deque 的数据结构 150 4.4.5 deque 的构造与内存管理 :ctor, push_back, push_front 152 4.4.6 deque 的元素操作:pop_back, pop_front, clear, erase, insert 161 4.5 stack 167 4.5.1 stack 概述 167 4.5.2 stack 定义式完整列表 167 4.5.3 stack 没有迭代器 168 4.5.4 以list 做为stack 的底层容器 168 4.6 queue 169 4.6.1 queue 概述 169 4.6.2 queue 定义式完整列表 170 4.6.3 queue 没有迭代器 171 4.6.4 以list 做为queue 的底层容器 171 4.7 heap(隐式表述,implicit representation) 172 4.7.1 heap 概述 172 4.7.2 heap 算法 174 push_heap 174 pop_heap 176 sort_heap 178 make_heap 180 4.7.3 heap 没有迭代器 181 4.7.4 heap 测试实例 181 4.8 priority-queue 183 4.8.1 priority-queue 概述 183 4.8.2 priority-queue 定义式完整列表 183 4.8.3 priority-queue 没有迭代器 185 4.8.4 priority-queue 测试实例 185 4.9 slist 186 4.9.1 slist 概述 186 4.9.2 slist 的节点 186 4.9.3 slist 的迭代器 188 4.9.4 slist 的数据结构 190 4.9.5 slist 的元素操作 191 第5章 关联式容器(associated containers) 197 5.1 树的导览 199 5.1.1 二元搜寻树(binary search tree) 200 5.1.2 平衡二元搜寻树(balanced binary search tree) 203 5.1.3 avl tree(adelson-velskii-landis tree) 203 5.1.4 单旋转(single rotation) 205 5.1.5 双旋转(double rotation) 206 5.2 rb-tree(红黑树) 208 5.2.1 插入节点 209 5.2.2 一个由上而下的程序 212 5.2.3 rb-tree 的节点设计 213 5.2.4 rb-tree 的迭代器 214 5.2.5 rb-tree 的数据结构 218 5.2.6 rb-tree 的构造与内存管理 221 5.2.7 rb-tree 的元素操作 223 元素插入动作 insert_equal 223 元素插入动作 insert_unique 224 真正的插入执行程序 __insert 224 调整rb-tree(旋转及改变颜色) 225 元素的搜寻 find 229 5.3 set 233 5.4 map 237 5.5 multiset 245 5.6 multimap 246 5.7 hashtable 247 5.7.1 hashtable 概述 247 线性探测(linear probing) 249 二次探测(quadratic probing) 251 分离链(separate chaining) 253 5.7.2 hashtable 的桶子(buckets)与节点(nodes) 253 5.7.3 hashtable 的迭代器 254 5.7.4 hashtable 的数据结构 256 5.7.5 hashtable 的构造与内存管理 258 插入动作(insert)与表格重整(resize) 259 判知元素的落脚处(bkt_num) 262 复制(copy_from)和整体删除(clear) 263 5.7.6 hashtable 运用实例(find, count) 264 5.7.7 hash functions 268 5.8 hash_set 270 5.9 hash_map 275 5.10 hash_multiset 279 5.11 hash_multimap 282 第6章 算法(algorithms) 285 6.1 算法概观 285 6.1.1 算法分析与复杂度表示 o( ) 286 6.1.2 stl算法总览 288 6.1.3 mutating algorithms - 会改变操作对象之值 291 6.1.4 nonmutating algorithms - 不改变操作对象之值 292 6.1.5 stl算法的一般形式 292 6.2 算法的泛化过程 294 6.3 数值算法 [stl_numeric.h] 298 6.3.1 运用实例 298 6.3.2 accumulate 299 6.3.3 adjacent_difference 300 6.3.4 inner_product 301 6.3.5 partial_sum 303 6.3.6 power 304 6.3.7 itoa 305 6.4 基本算法 [stl_algobase.h] 305 6.4.1 运用实例 305 6.4.2 equal 307 fill 308 fill_n 308 iter_swap 309 lexicographical_compare 310 max, min 312 mismatch 313 swap 314 6.4.3 copy,强化效率无所不用其极 314 6.4.4 copy_backward 326 6.5 set 相关算法(应用于有序区间) 328 6.5.1 set_union 331 6.5.2 set_intersection 333 6.5.3 set_difference 334 6.5.4 set_symmetric_difference 336 6.6 heap算法:make_heap, pop_heap, push_heap, sort_heap 338 6.7 其它算法 338 6.7.1 单纯的数据处理 338 adjacent_find 343 count 344 count_if 344 find 345 find_if 345 find_end 345 find_first_of 348 for_each 348 generate 349 generate_n 349 includes (应用于有序区间) 349 max_element 352 merge (应用于有序区间) 352 min_element 354 partition 354 remove 357 remove_copy 357 remove_if 357 remove_copy_if 358 replace 359 replace_copy 359 replace_if 359 replace_copy_if 360 reverse 360 reverse_copy 361 rotate 361 rotate_copy 365 search 365 search_n 366 swap_ranges 369 transform 369 unique 370 unique_copy 371 6.7.2 lower_bound (应用于有序区间) 375 6.7.3 upper_bound (应用于有序区间) 377 6.7.4 binary_search (应用于有序区间) 379 6.7.5 next_permutation 380 6.7.6 prev_permutation 382 6.7.7 random_shuffle 383 6.7.8 partial_sort / partial_sort_copy 386 6.7.9 sort 389 6.7.10 equal_range(应用于有序区间) 400 6.7.11 inplace_merge(应用于有序区间) 403 6.7.12 nth_element 409 6.7.13 merge sort 411 第7章 仿函数(functor,另名 函数对象function objects) 413 7.1 仿函数(functor)概观 413 7.2 可配接(adaptable)的关键 415 7.2.1 unary_function 416 7.2.2 binary_function 417 7.3 算术类(arithmetic)仿函数 418 plus, minus, multiplies, divides, modulus, negate, identity_element 7.4 关系类(relational)仿函数 420 equal_to, not_equal_to, greater, greater_equal, less, less_equal 7.5 逻辑运算类(logical)仿函数 422 logical_and, logical_or, logical_not 7.6 证同(identity)、选择(select)、投射(project) 423 identity, select1st, select2nd, project1st, project2nd 第8章 配接器(adapter) 425 8.1 配接器之概观与分类 425 8.1.1 应用于容器,container adapters 425 8.1.2 应用于迭代器,iterator adapters 425 运用实例 427 8.1.3 应用于仿函数,functor adapters 428 运用实例 429 8.2 container adapters 434 8.2.1 stack 434 8.2.2 queue 434 8.3 iterator adapters 435 8.3.1 insert iterators 435 8.3.2 reverse iterators 437 8.3.3 stream iterators (istream_iterator, ostream_iterator) 442 8.4 function adapters 448 8.4.1 对传回值进行逻辑否定:not1, not2 450 8.4.2 对参数进行系结(绑定):bind1st, bind2nd 451 8.4.3 用于函数合成:compose1, compose2(未纳入标准) 453 8.4.4 用于函数指针:ptr_fun 454 8.4.5 用于成员函数指针:mem_fun, mem_fun_ref 456 附录a 参考资料与推荐读物(bibliography) 461 附录b 侯捷网站简介 471 附录c stlport 的移植经验(by 孟岩) 473 borland c++builder 5 474 microsoft visual c++ 6.0 477 索引 481
ICS - Internet Component Suite - V8 - Delphi 7 to RAD Studio 10 Seattle ======================================================================= (Aka FPIETTE's Components) Revised: March 3, 2016 http://www.overbyte.be/ http://wiki.overbyte.be/ Table of content: ----------------- - Legal issues - Donate - Register - Contributions - Latest Versions - Version Control repository - Installation - Available VCL Components - Sample applications - About SSL - Support - Release notes - Midware - Known problems - Special thanks Legal issues: ------------- Copyright (C) 1997-2016 by Fran鏾is PIETTE Rue de Grady 24, 4053 Embourg, Belgium SSL implementation includes code written by Arno Garrels, Berlin, Germany, contact: ICS is freeware. This software is provided 'as-is', without any express or implied warranty. In no event will the author be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented, you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. 4. You must register this software by sending a picture postcard to the author. Use a nice stamp and mention your name, street address, EMail address and any comment you like to say. 5. As this code make use of OpenSSL, your rights are restricted by OpenSSL license as soon as you use any SSL feature. See http://www.openssl.org for details. Donate ------ ICS is freeware. You can use it without paying anything except the registration postcard (see "register" below). But of course donations are welcome. You can send cash (Euro currency or US Dollars) in an envelop to my street address or buy a gift certificate at Amazon in the UK. I will then use it to buy books. Here is the direct URL at Amazon UK (nearest to my home, please don't use another): http://www.amazon.co.uk/exec/obidos/gc-email-order1/ref=g_gc_email/202-6198323-6681414 For more generous amount, contact me by email. Register -------- ICS is freeware. If you use the components, you must register by sending a picture postcard showing the area you live in and some beautiful stamps for my kids who are stamp collectors. Do not use an envelop, I collect USED postcards sent to me. Write on the postcard that it is your ICS registration. Address your card to: Francois PIETTE, rue de Grady 24, 4053 Embourg, Belgium. Don't forget to mention your name, street address, EMail and web site. Contributions: -------------- ICS has been designed by Fran鏾is PIETTE but many other peoples are working on the components and sample programs. The history of changes in each source file list all developers having contributed (When no name is given, the change is by F. Piette). I can't list all contributors here but I want to specially thanks two specially active contributors: - Arno Garrels - Angus Robertson Latest versions: --------------- The latest versions of ICS can be downloaded from the ICS Wiki web site: http://wiki.overbyte.be/wiki/index.php/ICS_Download ICS V5 and V6 are archive releases no longer updated, last supported release was 2007. ICS V7 is a stable release that may still be updated for major bugs, but not for new releases of Delphi, latest it supported was XE3. ICS V8 is the current development release which is held in a public Version Control repository that is zipped each night for easy download. The download page above also includes the OpenSSL binaries needed to support SSL. ICS V8 supports Delphi 64-bit and Mac OS-X projects. Note that latest C++ Builder version supported is XE3 (lack of spare time, sorry). ICS V9 is in early development and is planned to support Android. There are no current plans for ICS for iOS. Version Control repository: --------------------------- svn://svn.overbyte.be/ics or http://svn.overbyte.be:8443/svn/ics (Usercode = ics, password = ics) Installation: ------------- ICS V8 has been designed for Embarcadero Delphi 2009 and up, and C++ Builder 2009 and up, but is fully compatible with Borland Delphi 7 and CodeGear 2006 and 2007. Embarcadero RAD Studio includes Delphi and C++ Builder. http://www.embarcadero.com/ With Delphi XE2 and later, VCL 64-bit Windows targets are supported for Delphi only. Currently FireMonkey is partly supported for Delphi only (there are still a few non-ported components). ICS for Mac OSX is currently experimental. The zip file has sub-directories in it. You must use the WinZip "Use folder names" option to restore this directory tree or you will have problems because the files would not be in their proper subdirectories. Please note most of these directories are differently named to ICS V7 and earlier, to ease support of multiple versions of Delphi and platforms, and to ease location of similar sample projects. Please don't install V8 over an existing V7 installation, it will be a mess of old and new. This is the new V8 sub-directory layout: .\ Info directory .\Install Component packages project groups for all versions .\Packages (was Delphi\Vc32) Delphi (7 and up) and C++Builder (2006 and up) packages projects .\Source (was Delphi\Vc32) ICS Delphi source code built into packages .\Source\Include (was Delphi\Vc32) .inc files (including OverbyteIcsDefs.inc) .\Source\Extras (was Delphi\Vc32) Extra source code not built into packages .\Source\zobj125 (was Delphi\Vc32) ZLIB C OBJ include files .\Lib Unit output directories for all package builds, subdirectories | for 2007+ will be created on building the packages \$(Config) Release / Debug | \$(Platform) Win32 / Win64 / OSX32 | \ D7..XE8, 10 Seattle includes .dcu and .dfm files for Delphi and .obj and .hpp files for C++ Builder .\Samples Delphi Win32/Win64 common source for all demos .\Samples\delphi\BroswerDemo Delphi Win32/Win64 Web Browser sample application (all Delphi versions) .\Samples\delphi\BroswerDemo\Resources Resource file, web pages and movie linked into browser demo .\Samples\delphi\FtpDemos Delphi Win32/Win64 FTP sample applications (all Delphi versions) .\Samples\delphi\MailNewsDemos Delphi Win32/Win64 SMTP, POP3, NNTP sample applications (all Delphi versions) .\Samples\delphi\MiscDemos Delphi Win32/Win64 Miscellaneous applications (all Delphi versions) .\Samples\delphi\OtherDemos Delphi Win32/Win64 DNS, Ping, SNMP, Syslog sample applications (all Delphi versions) .\Samples\delphi\PlatformDemos Delphi FireMonkey and cross-platform samples (Delphi XE2+) .\Samples\delphi\SocketDemos Delphi Win32/Win64 Socket sample applications (all Delphi versions) .\Samples\delphi\sslinternet Delphi Win32/Win64 SSL-enabled sample applications (all Delphi versions) .\Samples\delphi\WebDemos Delphi Win32/Win64 HTTP sample applications (all Delphi versions) .\Samples\delphi\WebDemos\WebAppServerData Directory for WebAppServ demo data files .\Samples\delphi\WebDemos\WebServData Directory for WebServ demo data files .\Samples\cpp\internet C++Builder sample applications .\Samples\cpp\internet\cb2006 C++Builder 2006 projects .\Samples\cpp\internet\cb2007 C++Builder 2007 projects .\Samples\cpp\internet\cb2009 C++Builder 2009 projects .\Samples\cpp\internet\cb2010 C++Builder 2010 projects .\Samples\cpp\internet\cbXE C++Builder XE projects .\Samples\cpp\internet\cbXE2 C++Builder XE2 projects UPGRADING and REINSTALLING Uninstall an existing ICS package (Menu | Component | Install Packages, select the component package and click Remove). Rename the old ICS directory and unzip to a new or empty directory, remove the old path from the library path and add either the new .\Source directory to the library path under Tools | Options |... or the appropriate .\Lib subdirectory according to version, ie .\Lib\Debug\Win32\D2007 for Delphi 2007. The latter has the advantage that the ICS source code won't be recompiled whenever your project is build. Also under Tools | Options |... add the new .\Source directory to the Browsing path. All DELPHI and C++ BUILDER VERSIONS/WIN32 Always upgrade your compiler with the latest update available from Embarcadero. Always update your system with http://windowsupdate.microsoft.com SSL or not SSL? By default the SSL code is compiled into the run-time package and additional SSL- enabled components are installed. In order to not compile the SSL code into the run-time package and to not install the SSL-Enabled components you need to remove the conditional define USE_SSL from both the run-time and design-time package. However if you do not build your applications with run-time packages it is recommended to build the packages with default settings. The SSL code will the be compiled into your applications depending on whether the conditional define USE_SSL is set in the project options or not (this requires having the .\Source directory in either in the library path or in projects Search path). Actual use of SSL in your applications also requires the OpenSSL files LIBEAY32.DLL and SSLEAY32.DLL being available somewhere in the path. Note different DLLs are needed for Win32 and Win64 applications. The ICS distribution includes the latest Win32 OpenSSL files in the .\OpenSSL-Win32 directory and the two main DLLs duplicated in .\Samples\delphi\sslinternet. Other OpenSSL files, including older and Win64, may be downloaded from: http://wiki.overbyte.be/wiki/index.php/ICS_Download INSTALLATION USING THE INSTALL PROJECT GROUPS For each Delphi and C++ Builder version one project group is provided in directory .\Install: Delphi 7 : D7Install.bpg Delphi 2006 : D2006Install.bdsgroup Delphi 2007 : D2007Install.groupproj Delphi 2009 : D2009Install.groupproj Delphi 2010 : D2010Install.groupproj Delphi XE : DXeInstall.groupproj Delphi XE2 : DXe2Install.groupproj // VCL only, no FireMonkey components Delphi XE2 : DXe2InstallVclFmx.groupproj // Both VCL and FireMonkey components Delphi XE3 : DXe3Install.groupproj // VCL only, no FireMonkey components Delphi XE3 : DXe3InstallVclFmx.groupproj // Both VCL and FireMonkey components Delphi XE4 : DXe4Install.groupproj // VCL only, no FireMonkey components Delphi XE4 : DXe4InstallVclFmx.groupproj // Both VCL and FireMonkey components Delphi XE5 : DXe5Install.groupproj // VCL only, no FireMonkey components Delphi XE5 : DXe5InstallVclFmx.groupproj // Both VCL and FireMonkey components Delphi XE6 : DXe6Install.groupproj // VCL only, no FireMonkey components Delphi XE6 : DXe6InstallVclFmx.groupproj // Both VCL and FireMonkey components Delphi XE7 : DXe7Install.groupproj // VCL only, no FireMonkey components Delphi XE7 : DXe7InstallVclFmx.groupproj // Both VCL and FireMonkey components Delphi XE8 : DXe8Install.groupproj // VCL only, no FireMonkey components Delphi XE8 : DXe8InstallVclFmx.groupproj // Both VCL and FireMonkey components Delphi 10 Seattle : D10SInstall.groupproj // VCL only, no FireMonkey components Delphi 10 Seattle : D10SInstallVclFmx.groupproj // Both VCL and FireMonkey components C++ Builder 2006 : CB2006Install.bdsgroup C++ Builder 2007 : CB2007Install.groupproj C++ Builder 2009 : CB2009Install.groupproj C++ Builder 2010 : CB2010Install.groupproj C++ Builder XE : CBXeInstall.groupproj C++ Builder XE2 : CBXe2Install.groupproj // VCL only no FireMonkey components C++ Builder XE2 : CBXe2InstallVclFmx.groupproj // Both VCL and FireMonkey components C++ Builder XE3 : CBXe3InstallVclFmx.groupproj // Both VCL and FireMonkey components 1 - Do a File/Open Project, navigate to the Install directory, select the correct file and open it. The project manager view should now display two package projects, one run-time and one design-time package. The run-time package name contains the "Run" suffix. The design-time package name contains the "Design" suffix. 2 - Select and Build the run-time package (do not install). 3 - Select and Install the design-time package. After a few seconds, you should have a dialog box telling you the package has been installed with a bunch of new components registered in the Tool Palette under "Overbyte ICS" and "Overbyte ICS SSL". Then do a "Save All" and a "Close All". 4 - One package is installed, called 'Overbyte ICS Design-Time Package for Delphi xxx'. 5 - Various directories under .\Samples\delphi\ include samples that illustrate use of all the ICS components, see later. FIREMONKEY CROSS PLATFORM PACKAGES: 1 - For XE2 and later, DXe?Install (where ? is the version) installs VCL components only, while DXe?InstallVclFmx also installs FireMonkey cross platform components (three run time packages). In order to use this feature first uninstall the old design-time package. 2 = Build all three run-time packages for all available platforms (32-bit and 64-bit Windows and Mac OS X) in the order they are listed in project manager. 3 - Next build and install the three design-time packages in the order they are listed in project manager. 4 - Three packages are installed, called: 'Overbyte ICS Common Design-Time Package for Delphi xxx' 'Overbyte ICS FMX Design-Time Package for Delphi xxx' 'Overbyte ICS VCL Design-Time Package for Delphi xxx' Note that the new packaging is still beta/alpha, both package names and included units might change in a future beta drop. The old VCL packages are still there however they do no longer support FireMonkey and of course only one set of packages can be installed in the IDE at the same time, if you want both VCL and FMX install DXe2InstallVclFmx.groupproj only. Currently the XE2 package cache is buggy and should be disabled by adding the -nocache parameter. 5 - The .\Samples\delphi\PlatformDemos\ folder contains FireMonkey sample projects that may all be built with FireMonkey for Mac OS X (and Windows). ALTERNATE INSTALLATION USING THE PACKAGE PROJECT FILES: For each Delphi and C++ Builder version two package project files exist in the .\Packages directory. One run-time and one design-time package project file. The run-time file name contains the "Run" suffix. The design-time file name contains the "Design" suffix. PACKAGE PROJECT FILE NAMES - VCL: Delphi 7 : OverbyteIcsD7Run.dpk, OverbyteIcsD7Design.dpk Delphi 2006 : OverbyteIcsD2006Run.bdsproj, OverbyteIcsD2006Design.bdsproj Delphi 2007 : OverbyteIcsD2007Run.dproj, OverbyteIcsD2007Design.dproj Delphi 2009 : OverbyteIcsD2009Run.dproj, OverbyteIcsD2009Design.dproj Delphi 2010 : OverbyteIcsD2010Run.dproj, OverbyteIcsD2010Design.dproj Delphi XE : OverbyteIcsDXeRun.dproj, OverbyteIcsDXeDesign.dproj Delphi XE2 : OverbyteIcsDXe2Run.dproj, OverbyteIcsDXe2Design.dproj Delphi XE3 : OverbyteIcsDXe3Run.dproj, OverbyteIcsDXe3Design.dproj Delphi XE4 : OverbyteIcsDXe4Run.dproj, OverbyteIcsDXe4Design.dproj Delphi XE5 : OverbyteIcsDXe5Run.dproj, OverbyteIcsDXe5Design.dproj Delphi XE6 : OverbyteIcsDXe6Run.dproj, OverbyteIcsDXe6Design.dproj Delphi XE7 : OverbyteIcsDXe7Run.dproj, OverbyteIcsDXe7Design.dproj Delphi XE8 : OverbyteIcsDXe8Run.dproj, OverbyteIcsDXe8Design.dproj Delphi 10 Seattle : OverbyteIcsD10SRun.dproj, OverbyteIcsD10SDesign.dproj C++ Builder 2006 : OverbyteIcsCB2006Run.bdsproj, OverbyteIcsCB2006Design.bdsproj C++ Builder 2007 : OverbyteIcsCB2007Run.cbproj, OverbyteIcsCB2007Design.cbproj C++ Builder 2009 : OverbyteIcsCB2009Run.cbproj, OverbyteIcsCB2009Design.cbproj C++ Builder 2010 : OverbyteIcsCB2010Run.cbproj, OverbyteIcsCB2010Design.cbproj C++ Builder XE : OverbyteIcsCBXeRun.cbproj, OverbyteIcsCBXeDesign.cbproj C++ Builder XE2 : OverbyteIcsCBXe2Run.cbproj, OverbyteIcsCBXe2Design.cbproj C++ Builder XE3 : OverbyteIcsCBXe3Run.cbproj, OverbyteIcsCBXe3Design.cbproj PACKAGE PROJECT FILE NAMES - FireMonkey and VCL: Delphi XE2 FMX/VCL : IcsCommonDXe2Run.dproj, IcsCommonDXe2Design.dproj Delphi XE2 VCL : IcsVclDXe2Run.dproj, IcsVclDXe2Design.dproj Delphi XE2 FMX : IcsFmxDXe2Run.dproj, IcsFmxDXe2Design.dproj Delphi XE3 FMX/VCL : IcsCommonDXe3Run.dproj, IcsCommonDXe3Design.dproj Delphi XE3 VCL : IcsVclDXe3Run.dproj, IcsVclDXe3Design.dproj Delphi XE3 FMX : IcsFmxDXe3Run.dproj, IcsFmxDXe3Design.dproj Delphi XE4 FMX/VCL : IcsCommonDXe4Run.dproj, IcsCommonDXe4Design.dproj Delphi XE4 VCL : IcsVclDXe4Run.dproj, IcsVclDXe4Design.dproj Delphi XE4 FMX : IcsFmxDXe4Run.dproj, IcsFmxDXe4Design.dproj Delphi XE5 FMX/VCL : IcsCommonDXe5Run.dproj, IcsCommonDXe5Design.dproj Delphi XE5 VCL : IcsVclDXe5Run.dproj, IcsVclDXe5Design.dproj Delphi XE5 FMX : IcsFmxDXe5Run.dproj, IcsFmxDXe5Design.dproj Delphi XE6 FMX/VCL : IcsCommonDXe6Run.dproj, IcsCommonDXe6Design.dproj Delphi XE6 VCL : IcsVclDXe6Run.dproj, IcsVclDXe6Design.dproj Delphi XE6 FMX : IcsFmxDXe6Run.dproj, IcsFmxDXe6Design.dproj Delphi XE7 FMX/VCL : IcsCommonDXe7Run.dproj, IcsCommonDXe7Design.dproj Delphi XE7 VCL : IcsVclDXe7Run.dproj, IcsVclDXe7Design.dproj Delphi XE7 FMX : IcsFmxDXe7Run.dproj, IcsFmxDXe7Design.dproj Delphi XE8 FMX/VCL : IcsCommonDXe8Run.dproj, IcsCommonDXe8Design.dproj Delphi XE8 VCL : IcsVclDXe8Run.dproj, IcsVclDXe8Design.dproj Delphi XE8 FMX : IcsFmxDXe8Run.dproj, IcsFmxDXe8Design.dproj Delphi 10 Seattle FMX/VCL: IcsCommonD10SRun.dproj, IcsCommonD10SDesign.dproj Delphi 10 Seattle VCL : IcsVclD10SRun.dproj, IcsVclD10SDesign.dproj Delphi 10 Seattle FMX : IcsFmxD10SRun.dproj, IcsFmxD10SDesign.dproj C++ Builder XE2 FMX/VCL : IcsCommonCBXe2Run.dproj, IcsCommonDXe2Design.dproj C++ Builder XE2 VCL : IcsVclCBXe2Run.dproj, IcsVclCBXe2Design.dproj C++ Builder XE2 FMX : IcsFmxCBXe2Run.dproj, IcsFmxCBXe2Design.dproj C++ Builder XE3 FMX/VCL : IcsCommonCBXe3Run.dproj, IcsCommonDXe3Design.dproj C++ Builder XE3 VCL : IcsVclCBXe3Run.dproj, IcsVclCBXe3Design.dproj C++ Builder XE3 FMX : IcsFmxCBXe3Run.dproj, IcsFmxCBXe3Design.dproj 1 - Open and Build the run-time package project (do not install!). 2 - Open and Install the design-time package project. (Do a File/Open Project, browse to the .\Packages directory. Select the correct file and open it. Then in the project manager view, right-click on the package, then click on either the Build or Install button.) 3 - For Delphi XE2 and later, a 64-bit run-time package can be built by changing the package target platform to 64-bit Windows. This has the same name as the 32-bit package, so a different package output directory needs to be specified in Tools / Options / Delphi Options for 64-bit Windows. After a few seconds, you should have a dialog box telling you the package has been installed with a bunch of new components registered in the Tool Palette under "Overbyte ICS" and "Overbyte ICS SSL". Then do a "Save All" and a "Close All". DELPHI 2006/WIN32, 2007/WIN32, 2009/WIN32, 2010/WIN32, XE/WIN32: Having installed the package, verify that the appropriate Win32 Library Path (Tools / Options / Delphi Options / Library - Win32 / Library Path) has been added, .\Lib subdirectory according to version, ie .\Lib\Debug\Win32\D2007 for Delphi 2007. If not, add it manually. It is not mandatory to add .\Lib to the global Delphi path, but it will be much easier for you because otherwise you'll have to add it to each project. DELPHI XE2/WIN32, XE3/WIN32, XE4/WIN32, XE5/WIN32, XE6/WIN32, XE7/WIN32, XE8/WIN32, 10 Seattle/WIN32, XE2/WIN64, XE3/WIN64, XE4/WIN64, XE5/WIN64, XE6/WIN64, XE7/WIN64, XE8/WIN64, 10 Seattle/WIN64: Similar to above, but the Library path is specified separately for 32-bit and 64-bit Windows Platforms. DELPHI 7: Add VC32 directory path to your library path (Tools menu / Environment Options / Library / Library Path. Add .\Lib\Debug\Win32\D7 path at the end of the existing path). SAMPLE DELPHI PROJECTS Once the package is installed, you may open the sample projects. The samples are split into several directories according to protocols, most with a project group that can be opened in all versions of Delphi. .\Samples\delphi\BroswerDemo .\Samples\delphi\FtpDemos\FtpDemos.bpg .\Samples\delphi\MailNewsDemos\MailNewsDemos.bpg .\Samples\delphi\MiscDemos\MiscDemos.bpg .\Samples\delphi\OtherDemos\OtherDemos.bpg .\Samples\delphi\PlatformDemos\XSamples.groupproj .\Samples\delphi\SocketDemos\SocketDemos.bpg .\Samples\delphi\sslinternet\SslDemos.bpg .\Samples\delphi\WebDemos\WebDemos.bpg Full details of the sample projects are shown later in this document. You might get some dialog box telling you that resource files are missing (they may not have been included in the zip file to save space) and are recreated by Delphi. It is OK. Any other error message is a problem you should fix. After all resource files have been recreated, you should see in the project manager a group of projects. To compile all samples in the group at once, do Project / Build all projects. This may take a few minutes. Note 1: Delphi may run out of memory if you ask to compile all projects at once. If you have not enough RAM, then compile each project individually. Note 2: Delphi has warnings which triggers a lot of messages for 100% OK code. You can turn those warnings off in the project/ options / Compiler messages and deselecting: "Deprecated symbol", "Platform symbol", "unsafe type", "unsafe code", "unsafe typecast". Those are intended for .NET and Linux portability. You can safely ignore them if you run windows. For you facility, I included a utility SetProjectOptions (source code, you must compile it) in the internet directory. This utility will update project options to disable the warnings. Once the components are all installed, you may open the sample projects each one after the other and compile them. For each project, do file/open and select the dpr file in the internet directory. Then Project/Build All. C++ BUILDER 2006, 2007, 2009, 2010, XE, XE2, XE3: Follow the installation procedure described for Delphi 2006. Just change the project group and package name: use CB2006, CBXe, etc, see above. You can't have Delphi 2006 and CBuilder 2006 packages installed at the same time in the IDE. So when switching from one to the other, be sure to remove the one you don't need. Building the FireMonkey CBXE2InstallVclFmx C++ packages for OSX may trigger an ILINK32 error, this is a bug in C++ Builder reported as QC #103668 the Win32 packages should build without errors. Once the components are all installed, you may open the sample projects each one after the other and compile them. For each project, do file/open and select the dpr file in the internet directory. Then Project/Build All. Projects are located in SAMPLES\CPP\INTERNET\CB2006\ (or CB2006, CBXE, etc) with a project group in each directory, OverbyteIcsCB2006Sam.bdsgroup, OverbyteIcsCBXe2Sam.groupproj, etc. It is likely that for each project, C++ Builder complains about a missing .res file. This is not a problem, C++ Builder will recreate it as needed. They have not been included to save space in the zip file. Once the components are all installed, you may open the sample projects each one after the other and compile them. For each project, do file/open and select the dpr file in the internet directory. Then Project/Build All. NOTES: - You may have an error message, using Delphi or C++ Builder complaining about Font.Charset, OldCreateOrder and other properties. Those are new properties in newer Delphi or C++ Builder versions, newer than the version you use. You can safely ignore those errors because those properties are not used by the components nor sample programs. You may encounter this error at run time. To avoid it, you must open each form at design time and ignore the error. Then recompile. If you don't ignore the error at design time, you'll have it at runtime ! - If you have Delphi or C++ Builder complaining about a file not found, add .\source directory to your library path. - If you are using C++ Builder you may encounter an error at link time such as "Unable to open file MWBCB30.LIB" (or other libs). This is a bug in C++ Builder. To solve it, you can edit project option file (right click in project manager) and remove any reference to the missing libraries. - Don't forget that the C++Builder components are located in .\delphi\vc32 which is object pascal source code (not a problem for C++Builder, just indicate that the *.pas files are displayed when installing). C++Builder will create the *.hpp files. There are some on-line help files in the VC32 directory. Available VCL Components ------------------------ - The following is a list of the files that should be installed in order to properly add all of the available components in this collection: > OverbyteIcsCharsetComboBox.pas Provides easy MIME charset selection > OverbyteIcsDnsQuery DNS lookup component - useful for getting MX records > OverbyteIcsDprUpdFix.pas IDE plugin for Delphi 2009 and 2010 to update old projects > OverbyteIcsEmulVT.pas ANSI terminal emulation in a control > OverbyteIcsFingCli.pas FINGER client protocol - Find information about user > OverbyteIcsFtpCli.pas FTP client protocol - file transfer > OverbyteIcsFtpSrv.pas FTP server protocol - file transfer > OverbyteIcsFtpSrvT.pas FTP server protocol - helpers > OverbyteIcsHttpAppServer.pas HTTP server protocol - used to build advanced web servers > OverbyteIcsHttpProt.pas HTTP client protocol - used by the web > OverbyteIcsHttpSrv.pas HTTP server protocol - used to build web servers > OverbyteIcsLogger.pas A component to log information > OverbyteIcsMimeDec.pas MIME component - decode file attach, use with POP3 > OverbyteIcsMultiProgressBar.pas A segmented progress bar > OverbyteIcsMultipartFtpDownloader.pas FTP client protocol - download one file using simultaneous connections to speedup download > OverbyteIcsMultipartHttpDownloader.pas HTTP client protocol - download one file using simultaneous connections to speedup download > OverbyteIcsNntpCli.pas NNTP client protocol - send and receive newsgroups messages > OverbyteIcsPing.pas ICMP echo protocol - ping a host > OverbyteIcsPop3Prot.pas POP3 client protocol - get mail from mail server > OverbyteIcsReg.pas Register design components > OverbyteIcsSmtpProt.pas SMTP client protocol - send mail to server > OverbyteIcsSmtpSrv.pas SMTP server protocol - receive mail from client > OverbyteIcsSnmpCli.pas SNMP client protocol - network management > OverbyteIcsSnmpMsgs.pas SNMP client protocol - message helper > OverbyteIcsSysLogClient.pas Syslog Client Protocol - receive syslog messages > OverbyteIcsSysLogDefs.pas Syslog Protocol - helpers > OverbyteIcsSysLogServer.pas Syslog Server Protocol - send syslog messages > OverbyteIcsTnCnx.pas TELNET client protocol - terminal emulation protocol > OverbyteIcsTnEmulVT.pas TELNET and ANSI terminal emulation combined > OverbyteIcsTnOptFrm.pas TELNET Client configuration form > OverbyteIcsTnScript.pas TELNET client protocol - with automation > OverbyteIcsWSocket.pas Winsock component - TCP, UDP, DNS,... > OverbyteIcsWSocketE.pas Register procedure and property editor for TWSocket > OverbyteIcsWSocketS.pas Winsock component for building servers > OverbyteIcsWSocketTS.pas Winsock component for building multithreaded servers - The following list support and utilities units: > OverbyteIcsAsn1Utils.pas ASN1 utilities (for TSnmpClient component) > OverbyteIcsAvlTrees.pas Implements a fast cache-like data storage > OverbyteIcsCharsetUtils.pas MIME-charset functions > OverbyteIcsCookies.pas Client Cookie Handling > OverbyteIcsCRC.pas 32 bit CRC computation > OverbyteIcsCsc.pas character set routines > OverbyteIcsDES.pas Implementation of the Data Encryption Standard (DES) > OverbyteIcsDigestAuth.pas HTTP Digest Access Authentication > OverbyteIcsFormDataDecoder.pas Decode a MIME data block as generated by a HTML form > OverbyteIcsHttpCCodZLib.pas Supports GZIP coding for HttpContCod > OverbyteIcsHttpContCod.pas HTTP Content Coding support, uses extra units > OverbyteIcsIcmp.pas ICMP protocol support, used by the PING component > OverbyteIcsIconv.pas Headers for iconv library (LGPL) > OverbyteIcsLIBEAY.pas Delphi encapsulation for LIBEAY32.DLL (OpenSSL) > OverbyteIcsMD4.pas Implementation of the MD4 Message-Digest Algorithm > OverbyteIcsMD5.pas Implementation of the MD5 Message-Digest Algorithm > OverbyteIcsMimeUtil.pas Support routines for MIME standard > OverbyteIcsMLang.pas A few header translations from MS mlang.h > OverbyteIcsNtlmMsgs.pas Client NTLM authentification messages used within HTTP protocol > OverbyteIcsNtlmSsp.pas Server NTLM authentification of user credentials using Windows SSPI > OverbyteIcsOneTimePw.pas One Time Password support functions, used by FTP > OverbyteIcsSHA1.pas Implementation of US Secure Hash Algorithm 1 (SHA1) > OverbyteIcsSocketUtils.pas Cross platform socket utilities for ICS > OverbyteIcsSSLEAY.pas Delphi encapsulation for SSLEAY32.DLL (OpenSSL) > OverbyteIcsSslSessionCache.pas A very fast external SSL-session-cache component > OverbyteIcsSslThrdLock.pas Implementation of OpenSsl thread locking (Windows); > OverbyteIcsSspi.pas A few header translations from MS sspi.h and security.h > OverbyteIcsStreams.pas Fast streams for ICS > OverbyteIcsThreadTimer.pas A custom timer class using custom timer messages from one or more threads > OverbyteIcsTicks64.pas GetTickCount64 support for all versions of Windows > OverbyteIcsTimeList.pas List of items with expiry times, used for WebSessions > OverbyteIcsTypes.pas Common types, mainly for backward compiler compatibility > OverbyteIcsURL.pas Support routines for URL handling > OverbyteIcsUtils.pas Vast number of common utilities, many supporting Unicode for D7/2007 > OverbyteIcsWSockBuf.pas FIFO buffers for TWSocket > OverbyteIcsWebSession.pas Web session support for THttpAppSrv and MidWare > OverbyteIcsWinnls.pas A few header translations for Unicode Normalization in winnls.h > OverbyteIcsWinsock.pas Some Winsock initialisations > OverbyteIcsWndControl.pas A class that encapsulates a windows message queue and a message map > OverbyteIcsZLibDll.pas Zlib support, interface to external zlib.dll functions > OverbyteIcsZlibHigh.pas Zlib support, high level interface for compression and decompression > OverbyteIcsZLibObj.pas Zlib support, interface to zlib linked C OBJ functions FireMonkey Cross Platform Support: ---------------------------------- For Delphi and C++ Builder XE2 and later, FireMonkey Desktop applications are an alternate to VCL Forms applications, supporting cross platforms of Windows 32-bit and 64-bit and Mac OS X (and perhaps other platforms in future). FireMonkey uses different visual components to VCL, while some non-visual components can be used for both VCL and FMX projects, while other components need special versions, such as ICS. Earlier betas of V8 used the conditional define "FMX" which is *no longer required in project options. Instead in your existing ICS FireMonkey app. add either "Ics.Fmx" to the unit scope names in project options or apply the following changes in the uses clause, rename: OverbyteIcsWndControl -> Ics.Fmx.OverbyteIcsWndControl OverbyteIcsWSocket -> Ics.Fmx.OverbyteIcsWSocket OverbyteIcsFtpCli -> Ics.Fmx.OverbyteIcsFtpCli OverbyteIcsFtpSrv -> Ics.Fmx.OverbyteIcsFtpSrv OverbyteIcsHttpProt -> Ics.Fmx.OverbyteIcsHttpProt OverbyteIcsWSocketS -> Ics.Fmx.OverbyteIcsWSocketS OverbyteIcsSmtpProt -> Ics.Fmx.OverbyteIcsSmtpProt.pas OverbyteIcsPop3Prot -> Ics.Fmx.OverbyteIcsPop3Prot.pas OverbyteIcsNntpCli -> Ics.Fmx.OverbyteIcsNntpCli.pas OverbyteIcsPing -> Ics.Fmx.OverbyteIcsPing.pas OverbyteIcsDnsQuery -> Ics.Fmx.OverbyteIcsDnsQuery.pas OverbyteIcsFingCli -> Ics.Fmx.OverbyteIcsFingCli.pas OverbyteIcsSslSessionCache -> Ics.Fmx.OverbyteIcsSslSessionCache.pas OverbyteIcsSslThrdLock -> Ics.Fmx.OverbyteIcsSslThrdLock.pas OverbyteIcsHttpSrv -> Ics.Fmx.OverbyteIcsHttpSrv.pas OverbyteIcsSocketUtils -> Ics.Fmx.OverbyteIcsSocketUtils.pas OverbyteIcsMultipartFtpDownloader -> Ics.Fmx.OverbyteIcsMultipartFtpDownloader.pas OverbyteIcsMultipartHttpDownloader -> Ics.Fmx.OverbyteIcsMultipartHttpDownloader.pas OverbyteIcsHttpAppServer -> Ics.Fmx.OverbyteIcsHttpAppServer.pas OverbyteIcsThreadTimer -> Ics.Fmx.OverbyteIcsThreadTimer.pas OverbyteIcsCharsetComboBox -> Ics.Fmx.OverbyteIcsCharsetComboBox.pas { Demo units } OverbyteIcsWebAppServerCounter -> Ics.Fmx.OverbyteIcsWebAppServerCounter OverbyteIcsWebAppServerMailer -> Ics.Fmx.OverbyteIcsWebAppServerMailer The list above is also the list of units that now have different names in the FireMonkey framework however most of them share the same source file. Dropping a ICS component on the form will add the correct unit name for each framework automatically (don't forget to disable the package cache as described above). Unit OverbyteIcsLibrary.pas has been *deprecated* and ICS IPv8 doesn't use it anymore. If you used it in your own code read the comment in OverbyteIcsLibrary.pas, search for "deprecated". Sample applications: -------------------- With V8, the sample applications are now grouped into directories according to general functionality, to make it easier to compare related samples. Many samples are similar. When searching for something, always look at the date the demos where created. The most recent is always the best code! In the lists below, ACTIVE!! indicates applications that are actively maintained to test and support new functionality in the ICS components. These may not be simplest samples, but are usually the first to try when learning about a component. Delphi Win32/Win64 Web Browser sample application ------------------------------------------------- .\Samples\delphi\BroswerDemo > FrameBrowserIcs.dpr Web Browser using HtmlViewer component - ACTIVE!! Note this sample needs HtmlViewer component installed Delphi Win32/Win64 FTP sample applications ------------------------------------------ .\Samples\delphi\FtpDemos\FtpDemos.bpg - Project group > OverbyteIcsBasFtp.dpr Basic FTP client program > OverbyteIcsConFtp.dpr Basic console mode FTP client > OverbyteIcsFtpAsy.dpr Example of asynchronous FTP client > OverbyteIcsFtpMulti.dpr Demo to do several FTP downloads in parallel to get a list of files > OverbyteIcsFtpMultipartDownload.dpr Demo to FTP download a single large file in several parts in parallel > OverbyteIcsFtpServ.dpr General purpose FTP server, uses TSocketServer - ACTIVE!! > OverbyteIcsFtpThrd.dpr Demo of multithreaded FTP client, see also FTPASY > OverbyteIcsFtpTst.dpr Basic graphical FTP client - ACTIVE!! Delphi Win32/Win64 SMTP, POP3, NNTP sample applications ------------------------------------------------------- .\Samples\delphi\MailNewsDemos\MailNewsDemos.bpg - Project group > OverbyteIcsBasNntp.dpr Basic NNTP client program > OverbyteIcsConPop3.dpr Basic console mode demo for POP3 (mail receive) > OverbyteIcsConSmtp.dpr Basic console mode demo for SMTP (mail send) > OverbyteIcsMailHtml.dpr Example of HTML formatted EMail sending, including embedded images - ACTIVE!! > OverbyteIcsMailRcv.dpr Internet EMail access using POP3 protocol - ACTIVE!! > OverbyteIcsMailSnd.dpr Example of EMail sending using SMTP, including file attach - ACTIVE!! > OverbyteIcsMailSndAsync.dpr Example of parallel EMail sending with multiple connections > OverbyteIcsMimeDemo.dpr Example of EMail decoding (attached files are extracted) - ACTIVE!! > OverbyteIcsNewsReader.dpr Example of TNntpCli component (Send/receive newsgroups) - ACTIVE!! > OverbyteIcsSmtpServer.dpr Internet EMail server using SMTP protocol - ACTIVE!! Delphi Win32/Win64 Miscellaneous applications --------------------------------------------- .\Samples\delphi\MiscDemos\MiscDemos.bpg - Project group > OverbyteIcsBufStrmTst.dpr Test of buffered stream classes > OverbyteIcsCacheTest.dpr Test of TCacheTree class used in TSslAvlSessionCache > OverbyteIcsMD4Test.dpr Test program for MD4 unit > OverbyteIcsMD5File.dpr Example of MD5 unit: computer MD5 checksum for files > OverbyteIcsMD5Test.dpr Test program for MD5 unit > OverbyteIcsOneTimePassword.dpr One Time Password test routines for OverByteIcsOneTimePw unit > OverbyteIcsSHA1Test.dpr Test program for SHA unit > OverbyteIcsThreadTimerDemo.dpr Demo for TIcsThreadTimer > OverbyteIcsTicks64Demo.dpr GetTickCount64 test routines for OverbyteIcsTicks64 unit > OverbyteIcsTimerDemo.dpr Very simple demo for TIcsTimer > OverByteIcsWndControlTest.dpr Test program for windows and threads Delphi Win32/Win64 DNS, Ping, SNMP, Syslog sample applications -------------------------------------------------------------- .\Samples\delphi\OtherDemos\OtherDemos.bpg - Project group > OverbyteIcsBatchDnsLookup.dpr Batch async DNS lookup using DnsLookup (IPv6 and IPv4) > OverbyteIcsConPing.dpr Basic console mode demo for ping component > OverbyteIcsDll1.dpr Demo showing how to use a TWSocket component in a DLL > OverbyteIcsDll2.dpr Demo showing how to use a THttpCli component in a DLL > OverbyteIcsDllTst.dpr Test program calling ICSDLL1 and ICSDLL2 > OverbyteIcsDnsLook.dpr Example of name resolution (IPv6 and IPv4) > OverbyteIcsDnsResolver.dpr Batch async DNS lookup event driven using DnsQuery > OverbyteIcsFinger.dpr Example of TFingerCli component > OverbyteIcsNsLookup.dpr Demo for the DnsQuery component > OverbyteIcsPingTst.dpr Demo for the ping component, includes trace route > OverbyteIcsSnmpCliTst.dpr Demo for SNMP (simple network management protocol) component > OverbyteIcsSysLogClientDemo.dpr Demo for SysLog client component > OverbyteIcsSysLogServerDemo.dpr Demo for SysLog server component Delphi FireMonkey cross-platform samples (Delphi XE2 and later) --------------------------------------------------------------- All these samples may be built for Mac OS X (and Windows). .\Samples\delphi\PlatformDemos\XSamples.groupproj > IcsCliDemo.dproj Example of client for SRVDEMO, IPV4 only > IcsTcpSrvIPv6.dproj Basic server without client forms, event-driven, IPv4/IPV6 > IcsConSmtp.dproj Basic console mode demo for SMTP (mail send) > IcsMailSnd.dproj Example of EMail sending using SMTP, including file attach > IcsMailRcv.dproj Internet EMail access using POP3 protocol > IcsHttpsTst.dproj Example of THttpCli component (GET), show many features > IcsWebServ.dproj Demo of HTTP server, uses TSocketServer > IcsWebAppServ.dproj Advanced HTTP server demo, uses WebServ, adds sessions > IcsFtpTst.dproj Basic graphical FTP client > IcsFtpServ.dproj General purpose FTP server, uses TSocketServer > IcsUdpLstn.dproj UDP listen demo > IcsUdpSend.dproj UDP send demo > IcsBatchDnsLookup.dproj Batch async DNS lookup using DnsLookup (IPv6 and IPv4) > IcsDll1.dproj Demo showing how to use a TWSocket component in a DLL > IcsDll2.dproj Demo showing how to use a THttpCli component in a DLL > IcsDllTst.dproj Test program calling ICSDLL1 and ICSDLL2 > IcsThreadTimerDemo.dproj Very simple demo for TIcsTimer Delphi Win32/Win64 Socket sample applications --------------------------------------------- .\Samples\delphi\SocketDemos\SocketDemos.bpg - Project group > OverbyteIcsBinCliDemo.dpr Client program to receive binary and delimited text data. Works with BinTcpSrv demo. > OverbyteIcsCliDemo.dpr Example of client for SRVDEMO, IPV4 only - ACTIVE!! > OverbyteIcsClient5.dpr Basic client GUI applications > OverbyteIcsClient7.dpr Simple client application demonstrating TWSocket > OverbyteIcsConCli1.dpr Basic client/server console applications > OverbyteIcsConCli2.dpr Basic client/server console applications with thread > OverbyteIcsConSrv1.dpr Basic server application in console mode > OverbyteIcsConUdpLstn.dpr Console application to listen for UDP messages > OverbyteIcsDynCli.dpr Demo of dynamically created TWSocket components > OverbyteIcsMtSrv.dpr Basic server, multi-threaded, see THRDSRV for better code > OverbyteIcsRecv.dpr Simple file receive (server), use with SENDER demo (client) > OverbyteIcsSender.dpr Simple file send (client), use with RECV demo (server) > OverbyteIcsServer5.dpr Basic server GUI applications > OverbyteIcsSocksTst.dpr How to use TWSocket with SOCKS protocol (firewall traversing) > OverbyteIcsSrvDemo.dpr Example of server using a TTable - ACTIVE!! > OverbyteIcsSrvTcp.dpr Basic server without client forms, event-driven > OverbyteIcsSvcTcp.dpr Same as SRVTCP but as an NT/2K/XP service > OverbyteIcsTWSChat.dpr Chat program (both client and server in a single program) > OverbyteIcsTcpSrv.dpr Basic server without client forms, event-driven, IPv4 only - ACTIVE!! > OverbyteIcsTcpSrvIPv6.dpr Basic server without client forms, event-driven, IPv4/IPV6 - ACTIVE!! > OverbyteIcsTelnetClient.dpr Telnet client using a TnEmulVT > OverbyteIcsThrdSrv.dpr Basic multithreaded TCP server, banner sent in main thread > OverbyteIcsThrdSrvV2.dpr Basic multithreaded TCP server, banner sent in worker thread > OverbyteIcsThrdSrvV3.dpr Basic TCP server showing how to use TWSocketThrdServer > OverbyteIcsTnDemo.dpr Telnet client using a TMemo > OverbyteIcsTnSrv.dpr Basic TCP server with client forms, event-driven > OverbyteIcsUdpLstn.dpr UDP listen demo > OverbyteIcsUdpSend.dpr UDP send demo Delphi Win32/Win64 SSL-enabled sample applications -------------------------------------------------- .\Samples\delphi\sslinternet\SslDemos.bpg - Project group > OverbyteIcsHttpsTst.dpr Example of TSslHttpCli component (GET) - ACTIVE!! > OverbyteIcsPemTool.dpr ICS Pem Certificate Tool - Create and import certificates in OpenSLL PEM format > OverbyteIcsSimpleSslCli.dpr Example of simple SSL client using TSslWSocket - ACTIVE!! > OverbyteIcsSimpleSslServer.dpr Example of SSL server using TSslWSocket - ACTIVE!! > OverbyteIcsSslFtpServ.dpr General purpose FTP SSL server, uses TSocketServer - ACTIVE!! > OverbyteIcsSslFtpTst.dpr Basic graphical FTP SSL client - ACTIVE!! > OverbyteIcsSslMailRcv.dpr Internet EMail access using POP3 protocol and SSL - ACTIVE!! > OverbyteIcsSslMailSnd.dpr Example of EMail sending using SMTP and SSL - ACTIVE!! > OverbyteIcsSslNewsRdr.dpr Example of TSslNntpCli component (Send/receive newsgroups) - ACTIVE!! > OverbyteIcsMsVerify.dpr Verify and show an OpenSSL certificate or certificate chain using class TMsCertChainEngine which uses MS crypto API - ACTIVE!! > OverbyteIcsSslSniSrv.dpr Test of Server Name Indication (SNI) in server mode - ACTIVE!! > OverbyteIcsSslWebServ.dpr Demo of HTTPS server, uses TSocketServer - ACTIVE!! > OverbyteIcsSslWebAppServer.dpr Advanced HTTPS server demo, uses WebServ, adds sessions - ACTIVE!! > OverbyteIcsSslSmtpServer.dpr Internet EMail server using SMTP protocol and SSL - ACTIVE!! Delphi Win32/Win64 HTTP sample applications ------------------------------------------- .\Samples\delphi\WebDemos\WebDemos.bpg - Project group > OverbyteIcsConHttp.dpr Basic console mode HTTP client > OverbyteIcsHttpAsp.dpr Example of THttpCli component with cookie (POST to an ASP page) > OverbyteIcsHttpAsy.dpr Example of THttpCli component with multiple async requests (GET) > OverbyteIcsHttpChk.dpr Example of THttpCli to check for valid URL using HEAD request > OverbyteIcsHttpDmo.dpr Simple HTTP client demo with proxy > OverbyteIcsHttpGet.dpr Example of THttpCli component (GET into a file) > OverbyteIcsHttpMultipartDownload.dpr Demo application for TMultipartHttpDownloader to download files using simultaneous connections > OverbyteIcsHttpPg.dpr Example of THttpCli component (POST to CGI script) > OverbyteIcsHttpPost.dpr Example of THttpCli component (POST), work with WebServ sample - ACTIVE!! > OverbyteIcsHttpThrd.dpr Example of THttpCli component (multi-threaded GET) > OverbyteIcsHttpTst.dpr Example of THttpCli component (GET), show many features - ACTIVE!! > OverbyteIcsIsapi.dll Example of FTP client component within an ISAPI extension > OverbyteIcsWebAppServer.dpr Advanced HTTP server demo, uses WebServ, adds sessions - ACTIVE!! > OverbyteIcsWebServ.dpr Demo of HTTP server, uses TSocketServer - ACTIVE!! Two samples are not in the project group since they need extra components installed > OverbyteIcsRestDemo.drp Demo program showing how to use REST API from Google and Yahoo > OverbyteIcsRestJsonDemo.drp Demo program showing how to use REST API from Google Search and JSON Sample Notes ------------ Note 1: Not all samples have been rewritten in C++ for C++ Builder. And those rewritten are frequently much simpler. So C++ Builder user: have a look at the Delphi sample too ! Note 2: Follow "UserMade" link on ICS web site to find more sample programs written by ICS users. As explained in the component installation, you may encounter an error loading a sample application or running it. This may be because the last time I loaded the form, I was using another Delphi or C++ Builder version which has new properties. You can safely ignore messages related to those new properties. They are not used in the samples. (The properties are CharSet, OldCreateOrder and others). You can also encounter error about duplicate resources. You can ignore them safely. If you have those errors, open each form in the IDE, ignore the error then recompile. If you don't open the form in the IDE, you'll get the errors at runtime and your program will abort. When installing a new version, always delete old dcu, obj, dcpil and always recompile everything ! Close everything before recompiling the library or packages. When installing a new version, be sure to unzip it in the same directory tree as the old one or you'll mess both versions. About SSL: ---------- TSslWSocket and TSslWSocketServer component are derived from the standard TWSocket and TWSocketServer component. The SSL code is compiled into the component only if you define USE_SSL symbol to your packages and projects. Just add USE_SSL to the defines in the project or package options and recompile everything. The components make use of LIBEAY32.DLL and SSLEAY32.DLL to handle SSL protocol stuff. The DLLs are dynamically loaded at runtime. It means that the DLLs will only be required at runtime when you first make use of a SSL function. Your applications will run on systems without OpenSSL DLLs as long as you don't call any SSL function. The files may be downloaded from: http://wiki.overbyte.be/wiki/index.php/ICS_Download Most ICS components have their SSL enabled counter part. They work exactly the same way as the regular component except when SSL specific stuff is needed, for example certificates. To support SSL stuff, the SSL-enabled version use some new properties, events and methods. Many sample programs have their SSL-enabled counter part in a separate sources located in SslInternet folder. SSL certificates: To make use of SSL, you frequently need certificates. I provide some demo certificates I built using command line OpenSSL tool. PEM certificates can be opened by a text editor, LF as well as CRLF are allowed as line breaks. CACERT.PEM : A demo certificate for "Example CA" 01CERT.PEM : A demo certificate which is signed by CACERT.PEM 01KEY.PEM : A demo private key for 01CERT.PEM Passphrase is "password". CLIENT.PEM : A demo certificate and private key. Passphrase is "password". SERVER.PEM : A demo certificate and private key. Passphrase is "password". ROOT.PEM : A demo CA certificate. Passphrase is "password". TRUSTEDCABUNDLE.PEM : A demo CA file in PEM format containing multiple well known root CA certificates to be specified in property CA Path of the demo applications. Read the comments included in this file. 6F6359FC.0 : Located in sub directory SslInternet\TrustedCaStore, it's the file CACERT.PEM stored with a hashed file name. Directory TrustedCaStore can be specified in property CA Path of the demo applications. For details about certificate, see the excellent book: "Network security with OpenSSL", O'Reilly, ISBN 10: 0-596-00270-X The SSL demo project OverbyteIcsPemTool may be used to create self signed PEM certificates, certificate requests for commercial use, to convert existing certificates in the Windows Certificate Store to PEM format understood by OpenSSL and to examine PEM certificates. You will find more information in IcsSslHowTo.txt file. Commercial SSL certificates: To avoid browsers giving certificate warning messages, you need to purchase a SSL certificate from one of numerous companies, such as Verisign, Thawte GeoTrust or RapidSSL. Prices vary dramatically and are often cheaper from resellers such as Servertastic than from the main issuing companies. The main purpose of an SSL certificate is to prove the identity of the owner of a web site, ideally the company behind the web site. That usually requires paper work identifying the company is submitted and also proof the domain being protected is owned by that company, it usually also involves telephone calls. Such certificates are usually called fully validated and cost $120 or more each year for a single domain, ie secure.website.com. Wild card certificates cost $350 or more, but protect multiple sub-domains, ie web.website.com as well. Extended Validation certificates cost from $450 a year, and show the company name in green in the address bar. For testing and simple use, instant issued SSL certificates cost from $15 per year and protect a single domain only with automated checking reducing the cost (an email to admin@website.com to prove you receive email for the domain, perhaps a telephone call as well). Note these instant certificates do not include a company name. To buy and install an SSL certificate for use with ICS and OpenSSL follow these steps: 1 - Build the SSL demo project OverbyteIcsPemTool. Take Extras, Create Certificate Requests, fill in the various fields (check other certificates if uncertain, the Common Name is the domain to protect, ie secure.website.com and E-Mail should be an email address at the than domain, ideally admin or administrator, 2048 bits. Click Create, and specify two file names, first for the private key (mykey.pem) then the certificate request file (myreq.pem). The request can also be done using OpenSSL command line arguments, or you can build it into your own application. 2 - Choose you SSL supplier and certificate type, at some point during the ordering process you will be asked for the certificate request, so open the PEM file you saved with a text editor and copy the base64 encoded block starting -BEGIN CERTIFICATE REQUEST- into the web form. It should be decoded and displayed so you check it's correct. The private key is not needed for the certificate to be issued. At this point the validation process starts as mentioned above, which might take hours or weeks to complete. 3 - Eventually the SSL certificate should be issued, either by email or made available to download from the supplier's web site. It should be in X.509 format in a base64 encoded block starting -BEGIN CERTIFICATE- which should be saved as a PEM file (mycert.pem). There should also be an Intermediate CA certificate, with which your new certificate was signed, which should also be saved as a file (mycacert.pem). This may also be downloadable from the supplier as a bundle file and should be common to any certificates they issue, ie RapidSSL_CA_bundle.pem. 4 - The OverbyteIcsPemTool tool has a View PEM button that allows examination of your new PEM files. 5 - The three PEM files now need to be attached to the SslContext component in your application, with properties SslCertFile, SslPrivKeyFile and SslCAFile. The request certificate file has no further use. Support: -------- There is a mailing list to discuss F. Piette's components and applications. To subscribe surf to http://lists.elists.org/mailman/listinfo/twsocket. Do not use an aliased EMail address, use your real EMail address, the one you'll use to post messages. After asking for subscription, you'll receive a confirmation email you must reply to it or you will _not_ be added to the subscriber's list (this is to check for email path and also make sure someone doesn't subscribe you without your consent). Once you have been registered with the mailing list processor, you can send messages to twsocket@elists.org. Every subscriber will receive a copy of your message. I will respond, but anybody is welcome to respond to each other's messages. So every body can share his expertise. There are many other useful mailing lists at http://www.elists.org ! Before asking a question, browse the message archive you can download from the support page on the web site (click the "support" button from main page) and from the mailing list web site http://lists.elists.org/mailman/listinfo/twsocket. Google is also archiving the list with some delay. If you found a bug, please make a short program that reproduces the problem attach it to a message addressed to me. If I can reproduce the problem, I can find a fix ! Do not send exe file but just source code and instructions. Always use the latest version (beta if any) before reporting any bug. You are also encouraged to use the support mailing list to ask for enhancements. You are welcome to post your own code. The support mailing list has sometimes a heavy traffic. If it is too much for you, you can select "digest" mode in which mailing list processor will mail you only one big message per day. To select digest mode goto http://lists.elists.org/mailman/listinfo/twsocket. You can also subscribe to another mailing list called twsocket-announce which will receive only very few messages when major bug fixes or updates are done. The subscription process is the same as for the other mailing list. See above procedure. Release notes ------------- There is no global release notes. Each component and sample has his own history. You can find those histories in the comment in the beginning of each source file. There are also a bunch of useful comments in the source code. You should at least browse the source for the components you are interested in. MidWare ------- If you wants to build client/server applications using TCP/IP protocol, you can do it easily with ICS. But you can do it much more easily using another freeware product from Fran鏾is Piette: MidWare. Available from the same web site http://www.overbyte.be. francois.piette@overbyte.be francois.piette@swing.be http://www.overbyte.be/ http://wiki.overbyte.be/
JAVA相关基础知识 1、面向对象的特征有哪些方面 1.抽象: 抽象就是忽略一个主题与当前目标无关的那些方面,以便更充分地注意与当前目标有关的方面。抽象并不打算了解全部问题,而只是选择其的一部分,暂时不用部分细节。抽象包括两个方面,一是过程抽象,二是数据抽象。 2.继承: 继承是一种联结类的层次模型,并且允许和鼓励类的重用,它提供了一种明确表述共性的方法。对象的一个新类可以从现有的类派生,这个过程称为类继承。新类继承了原始类的特性,新类称为原始类的派生类(子类),而原始类称为新类的基类(父类)。派生类可以从它的基类那里继承方法和实例变量,并且类可以修改或增加新的方法使之更适合特殊的需要。 3.封装: 封装是把过程和数据包围起来,对数据的访问只能通过已定义的界面。面向对象计算始于这个基本概念,即现实世界可以被描绘成一系列完全自治、封装的对象,这些对象通过一个受保护的接口访问其他对象。 4. 多态性: 多态性是指允许不同类的对象对同一消息作出响应。多态性包括参数化多态性和包含多态性。多态性语言具有灵活、抽象、行为共享、代码共享的优势,很好的解决了应用程序函数同名问题。 2、String是最基本的数据类型吗? 基本数据类型包括byte、int、char、long、float、double、boolean和short。 java.lang.String类是final类型的,因此不可以继承这个类、不能修改这个类。为了提高效率节省空间,我们应该用StringBuffer类 3、int 和 Integer 有什么区别 Java 提供两种不同的类型:引用类型和原始类型(或内置类型)。Int是java的原始数据类型,Integer是java为int提供的封装类。Java为每个原始类型提供了封装类。 原始类型封装类 booleanBoolean charCharacter byteByte shortShort intInteger longLong floatFloat doubleDouble 引用类型和原始类型的行为完全不同,并且它们具有不同的语义。引用类型和原始类型具有不同的特征和用法,它们包括:大小和速度问题,这种类型以哪种类型的数据结构存储,当引用类型和原始类型用作某个类的实例数据时所指定的缺省值。对象引用实例变量的缺省值为 null,而原始类型实例变量的缺省值与它们的类型有关。 4、String 和StringBuffer的区别 JAVA平台提供了两个类:String和StringBuffer,它们可以储存和操作字符串,即包含多个字符的字符数据。这个String类提供了数值不可改变的字符串。而这个StringBuffer类提供的字符串进行修改。当你知道字符数据要改变的时候你就可以使用StringBuffer。典型地,你可以使用StringBuffers来动态构造字符数据。 5、运行时异常与一般异常有何异同? 异常表示程序运行过程可能出现的非正常状态,运行时异常表示虚拟机的通常操作可能遇到的异常,是一种常见运行错误。java编译器要求方法必须声明抛出可能发生的非运行时异常,但是并不要求必须声明抛出未被捕获的运行时异常。 6、说出Servlet的生命周期,并说出Servlet和CGI的区别。 Servlet被服务器实例化后,容器运行其init方法,请求到达时运行其service方法,service方法自动派遣运行与请求对应的doXXX方法(doGet,doPost)等,当服务器决定将实例销毁的时候调用其destroy方法。 与cgi的区别在于servlet处于服务器进程,它通过多线程方式运行其service方法,一个实例可以服务于多个请求,并且其实例一般不会销毁,而CGI对每个请求都产生新的进程,服务完成后就销毁,所以效率上低于servlet。 7、说出ArrayList,Vector, LinkedList的存储性能和特性 ArrayList和Vector都是使用数组方式存储数据,此数组元素数大于实际存储的数据以便增加和插入元素,它们都允许直接按序号索引元素,但是插入元素要涉及数组元素移动等内存操作,所以索引数据快而插入数据慢,Vector由于使用了synchronized方法(线程安全),通常性能上较ArrayList差,而LinkedList使用双向链表实现存储,按序号索引数据需要进行前向或后向遍历,但是插入数据时只需要记录本项的前后项即可,所以插入速度较快。 8、EJB是基于哪些技术实现的?并说出SessionBean和EntityBean的区别,StatefulBean和StatelessBean的区别。 EJB包括Session Bean、Entity Bean、Message Driven Bean,基于JNDI、RMI、JAT等技术实现。 SessionBean在J2EE应用程序被用来完成一些服务器端的业务操作,例如访问数据库、调用其他EJB组件。EntityBean被用来代表应用系统用到的数据。 对于客户机,SessionBean是一种非持久性对象,它实现某些在服务器上运行的业务逻辑。 对于客户机,EntityBean是一种持久性对象,它代表一个存储在持久性存储器的实体的对象视图,或是一个由现有企业应用程序实现的实体。 Session Bean 还可以再细分为 Stateful Session Bean 与 Stateless Session Bean ,这两种的 Session Bean都可以将系统逻辑放在 method之执行,不同的是 Stateful Session Bean 可以记录呼叫者的状态,因此通常来说,一个使用者会有一个相对应的 Stateful Session Bean 的实体。Stateless Session Bean 虽然也是逻辑组件,但是他却不负责记录使用者状态,也就是说当使用者呼叫 Stateless Session Bean 的时候,EJB Container 并不会找寻特定的 Stateless Session Bean 的实体来执行这个 method。换言之,很可能数个使用者在执行某个 Stateless Session Bean 的 methods 时,会是同一个 Bean 的 Instance 在执行。从内存方面来看, Stateful Session Bean 与 Stateless Session Bean 比较, Stateful Session Bean 会消耗 J2EE Server 较多的内存,然而 Stateful Session Bean 的优势却在于他可以维持使用者的状态。 9、Collection 和 Collections的区别。   Collection是集合类的上级接口,继承与他的接口主要有Set 和List. Collections是针对集合类的一个帮助类,他提供一系列静态方法实现对各种集合的搜索、排序、线程安全化等操作。 10、&和&&的区别。 &是位运算符,表示按位与运算,&&是逻辑运算符,表示逻辑与(and)。 11、HashMapHashtable的区别。 HashMapHashtable的轻量级实现(非线程安全的实现),他们都完成了Map接口,主要区别在于HashMap允许空(null)键值(key),由于非线程安全,效率上可能高于Hashtable。 HashMap允许将null作为一个entry的key或者value,而Hashtable不允许。 HashMapHashtable的contains方法去掉了,改成containsvalue和containsKey。因为contains方法容易让人引起误解。 Hashtable继承自Dictionary类,而HashMap是Java1.2引进的Map interface的一个实现。 最大的不同是,Hashtable的方法是Synchronize的,而HashMap不是,在多个线程访问Hashtable时,不需要自己为它的方法实现同步,而HashMap 就必须为之提供外同步。 Hashtable和HashMap采用的hash/rehash算法都大概一样,所以性能不会有很大的差异。 12、final, finally, finalize的区别。   final 用于声明属性,方法和类,分别表示属性不可变,方法不可覆盖,类不可继承。 finally是异常处理语句结构的一部分,表示总是执行。 finalize是Object类的一个方法,在垃圾收集器执行的时候会调用被回收对象的此方法,可以覆盖此方法提供垃圾收集时的其他资源回收,例如关闭文件等。 13、sleep() 和 wait() 有什么区别? sleep是线程类(Thread)的方法,导致此线程暂停执行指定时间,给执行机会给其他线程,但是监控状态依然保持,到时后会自动恢复。调用sleep不会释放对象锁。 wait是Object类的方法,对此对象调用wait方法导致本线程放弃对象锁,进入等待此对象的等待锁定池,只有针对此对象发出notify方法(或notifyAll)后本线程才进入对象锁定池准备获得对象锁进入运行状态。 14、Overload和Override的区别。Overloaded的方法是否可以改变返回值的类型? 方法的重写Overriding和重载Overloading是Java多态性的不同表现。重写Overriding是父类与子类之间多态性的一种表现,重载Overloading是一个类多态性的一种表现。如果在子类定义某方法与其父类有相同的名称和参数,我们说该方法被重写 (Overriding)。子类的对象使用这个方法时,将调用子类的定义,对它而言,父类的定义如同被"屏蔽"了。如果在一个类定义了多个同名的方法,它们或有不同的参数个数或有不同的参数类型,则称为方法的重载(Overloading)。Overloaded的方法是可以改变返回值的类型。 15、error和exception有什么区别? error 表示恢复不是不可能但很困难的情况下的一种严重问题。比如说内存溢出。不可能指望程序能处理这样的情况。 exception 表示一种设计或实现问题。也就是说,它表示如果程序运行正常,从不会发生的情况。 16、同步和异步有何异同,在什么情况下分别使用他们?举例说明。 如果数据将在线程间共享。例如正在写的数据以后可能被另一个线程读到,或者正在读的数据可能已经被另一个线程写过了,那么这些数据就是共享数据,必须进行同步存取。 当应用程序在对象上调用了一个需要花费很长时间来执行的方法,并且不希望让程序等待方法的返回时,就应该使用异步编程,在很多情况下采用异步途径往往更有效率。 17、abstract class和interface有什么区别? 声明方法的存在而不去实现它的类被叫做抽象类(abstract class),它用于要创建一个体现某些基本行为的类,并为该类声明方法,但不能在该类实现该类的情况。不能创建abstract 类的实例。然而可以创建一个变量,其类型是一个抽象类,并让它指向具体子类的一个实例。不能有抽象构造函数或抽象静态方法。Abstract 类的子类为它们父类的所有抽象方法提供实现,否则它们也是抽象类为。取而代之,在子类实现该方法。知道其行为的其它类可以在类实现这些方法。 接口(interface)是抽象类的变体。在接口,所有方法都是抽象的。多继承性可通过实现这样的接口而获得。接口的所有方法都是抽象的,没有一个有程序体。接口只可以定义static final成员变量。接口的实现与子类相似,除了该实现类不能从接口定义继承行为。当类实现特殊接口时,它定义(即将程序体给予)所有这种接口的方法。然后,它可以在实现了该接口的类的任何对象上调用接口的方法。由于有抽象类,它允许使用接口名作为引用变量的类型。通常的动态联编将生效。引用可以转换到接口类型或从接口类型转换,instanceof 运算符可以用来决定某对象的类是否实现了接口。 18、heap和stack有什么区别。 栈是一种线形集合,其添加和删除元素的操作应在同一段完成。栈按照后进先出的方式进行处理。 堆是栈的一个组成元素 19、forward 和redirect的区别 forward是服务器请求资源,服务器直接访问目标地址的URL,把那个URL的响应内容读取过来,然后把这些内容再发给浏览器,浏览器根本不知道服务器发送的内容是从哪儿来的,所以它的地址栏还是原来的地址。 redirect就是服务端根据逻辑,发送一个状态码,告诉浏览器重新去请求那个地址,一般来说浏览器会用刚才请求的所有参数重新请求,所以session,request参数都可以获取。 20、EJB与JAVA BEAN的区别? Java Bean 是可复用的组件,对Java Bean并没有严格的规范,理论上讲,任何一个Java类都可以是一个Bean。但通常情况下,由于Java Bean是被容器所创建(如Tomcat)的,所以Java Bean应具有一个无参的构造器,另外,通常Java Bean还要实现Serializable接口用于实现Bean的持久性。Java Bean实际上相当于微软COM模型的本地进程内COM组件,它是不能被跨进程访问的。Enterprise Java Bean 相当于DCOM,即分布式组件。它是基于Java的远程方法调用(RMI)技术的,所以EJB可以被远程访问(跨进程、跨计算机)。但EJB必须被布署在诸如Webspere、WebLogic这样的容器,EJB客户从不直接访问真正的EJB组件,而是通过其容器访问。EJB容器是EJB组件的代理,EJB组件由容器所创建和管理。客户通过容器来访问真正的EJB组件。 21、Static Nested Class 和 Inner Class的不同。 Static Nested Class是被声明为静态(static)的内部类,它可以不依赖于外部类实例被实例化。而通常的内部类需要在外部类实例化后才能实例化。 22、JSP动态INCLUDE与静态INCLUDE的区别? 动态INCLUDE用jsp:include动作实现 它总是会检查所含文件的变化,适合用于包含动态页面,并且可以带参数。 静态INCLUDE用include伪码实现,定不会检查所含文件的变化,适用于包含静态页面 23、什么时候用assert。 assertion(断言)在软件开发是一种常用的调试方式,很多开发语言都支持这种机制。在实现,assertion就是在程序的一条语句,它对一个boolean表达式进行检查,一个正确程序必须保证这个boolean表达式的值为true;如果该值为false,说明程序已经处于不正确的状态下,系统将给出警告或退出。一般来说,assertion用于保证程序最基本、关键的正确性。assertion检查通常在开发和测试时开启。为了提高性能,在软件发布后,assertion检查通常是关闭的。 24、GC是什么? 为什么要有GC?   GC是垃圾收集的意思(Gabage Collection),内存处理是编程人员容易出现问题的地方,忘记或者错误的内存回收会导致程序或系统的不稳定甚至崩溃,Java提供的GC功能可以自动监测对象是否超过作用域从而达到自动回收内存的目的,Java语言没有提供释放已分配内存的显示操作方法。 25、short s1 = 1; s1 = s1 + 1;有什么错? short s1 = 1; s1 += 1;有什么错? short s1 = 1; s1 = s1 + 1; (s1+1运算结果是int型,需要强制转换类型) short s1 = 1; s1 += 1;(可以正确编译) 26、Math.round(11.5)等於多少? Math.round(-11.5)等於多少? Math.round(11.5)==12 Math.round(-11.5)==-11 round方法返回与参数最接近的长整数,参数加1/2后求其floor. 27、String s = new String("xyz");创建了几个String Object? 两个 28、设计4个线程,其两个线程每次对j增加1,另外两个线程对j每次减少1。写出程序。 以下程序使用内部类实现线程,对j增减的时候没有考虑顺序问题。 public class ThreadTest1{ private int j; public static void main(String args[]){ ThreadTest1 tt=new ThreadTest1(); Inc inc=tt.new Inc(); Dec dec=tt.new Dec(); for(int i=0;i<2;i++){ Thread t=new Thread(inc); t.start(); t=new Thread(dec); t.start(); } } private synchronized void inc(){ j++; System.out.println(Thread.currentThread().getName()+"-inc:"+j); } private synchronized void dec(){ j--; System.out.println(Thread.currentThread().getName()+"-dec:"+j); } class Inc implements Runnable{ public void run(){ for(int i=0;i<100;i++){ inc(); } } } class Dec implements Runnable{ public void run(){ for(int i=0;i<100;i++){ dec(); } } } } 29、Java有没有goto? java的保留字,现在没有在java使用。 30、启动一个线程是用run()还是start()? 启动一个线程是调用start()方法,使线程所代表的虚拟处理机处于可运行状态,这意味着它可以由JVM调度并执行。这并不意味着线程就会立即运行。run()方法可以产生必须退出的标志来停止一个线程。 31、EJB包括(SessionBean,EntityBean)说出他们的生命周期,及如何管理事务的? SessionBean:Stateless Session Bean 的生命周期是由容器决定的,当客户机发出请求要建立一个Bean的实例时,EJB容器不一定要创建一个新的Bean的实例供客户机调用,而是随便找一个现有的实例提供给客户机。当客户机第一次调用一个Stateful Session Bean 时,容器必须立即在服务器创建一个新的Bean实例,并关联到客户机上,以后此客户机调用Stateful Session Bean 的方法时容器会把调用分派到与此客户机相关联的Bean实例。 EntityBean:Entity Beans能存活相对较长的时间,并且状态是持续的。只要数据库的数据存在,Entity beans就一直存活。而不是按照应用程序或者服务进程来说的。即使EJB容器崩溃了,Entity beans也是存活的。Entity Beans生命周期能够被容器或者 Beans自己管理。 EJB通过以下技术管理实务:对象管理组织(OMG)的对象实务服务(OTS),Sun Microsystems的Transaction Service(JTS)、Java Transaction API(JTA),开发组(X/Open)的XA接口。 32、应用服务器有那些? BEA WebLogic Server,IBM WebSphere Application Server,Oracle9i Application Server,jBoss,Tomcat 33、给我一个你最常见到的runtime exception。 ArithmeticException, ArrayStoreException, BufferOverflowException, BufferUnderflowException, CannotRedoException, CannotUndoException, ClassCastException, CMMException, ConcurrentModificationException, DOMException, EmptyStackException, IllegalArgumentException, IllegalMonitorStateException, IllegalPathStateException, IllegalStateException, ImagingOpException, IndexOutOfBoundsException, MissingResourceException, NegativeArraySizeException, NoSuchElementException, NullPointerException, ProfileDataException, ProviderException, RasterFormatException, SecurityException, SystemException, UndeclaredThrowableException, UnmodifiableSetException, UnsupportedOperationException 34、接口是否可继承接口? 抽象类是否可实现(implements)接口? 抽象类是否可继承实体类(concrete class)? 接口可以继承接口。抽象类可以实现(implements)接口,抽象类是否可继承实体类,但前提是实体类必须有明确的构造函数。 35、List, Set, Map是否继承自Collection接口? List,Set是,Map不是 36、说出数据连接池的工作机制是什么? J2EE服务器启动时会建立一定数量的池连接,并一直维持不少于此数目的池连接。客户端程序需要连接时,池驱动程序会返回一个未使用的池连接并将其表记为忙。如果当前没有空闲连接,池驱动程序就新建一定数量的连接,新建连接的数量有配置参数决定。当使用的池连接调用完成后,池驱动程序将此连接表记为空闲,其他调用就可以使用这个连接。 37、abstract的method是否可同时是static,是否可同时是native,是否可同时是synchronized? 都不能 38、数组有没有length()这个方法? String有没有length()这个方法? 数组没有length()这个方法,有length的属性。String有有length()这个方法。 39、Set里的元素是不能重复的,那么用什么方法来区分重复与否呢? 是用==还是equals()? 它们有何区别? Set里的元素是不能重复的,那么用iterator()方法来区分重复与否。equals()是判读两个Set是否相等。 equals()和==方法决定引用值是否指向同一对象equals()在类被覆盖,为的是当两个分离的对象的内容和类型相配的话,返回真值。 40、构造器Constructor是否可被override? 构造器Constructor不能被继承,因此不能重写Overriding,但可以被重载Overloading。 41、是否可以继承String类? String类是final类故不可以继承。 42、swtich是否能作用在byte上,是否能作用在long上,是否能作用在String上? switch(expr1),expr1是一个整数表达式。因此传递给 switch 和 case 语句的参数应该是 int、 short、 char 或者 byte。long,string 都不能作用于swtich。 43、try {}里有一个return语句,那么紧跟在这个try后的finally {}里的code会不会被执行,什么时候被执行,在return前还是后? 会执行,在return前执行。 44、编程题: 用最有效率的方法算出2乘以8等於几? 2 << 3 45、两个对象值相同(x.equals(y) == true),但却可有不同的hash code,这句话对不对? 不对,有相同的hash code。 46、当一个对象被当作参数传递到一个方法后,此方法可改变这个对象的属性,并可返回变化后的结果,那么这里到底是值传递还是引用传递? 是值传递。Java 编程语言只有值传递参数。当一个对象实例作为一个参数被传递到方法时,参数的值就是对该对象的引用。对象的内容可以在被调用的方法改变,但对象的引用是永远不会改变的。 47、当一个线程进入一个对象的一个synchronized方法后,其它线程是否可进入此对象的其它方法? 不能,一个对象的一个synchronized方法只能由一个线程访问。 48、编程题: 写一个Singleton出来。 Singleton模式主要作用是保证在Java应用程序,一个类Class只有一个实例存在。 一般Singleton模式通常有几种种形式: 第一种形式: 定义一个类,它的构造函数为private的,它有一个static的private的该类变量,在类初始化时实例话,通过一个public的getInstance方法获取对它的引用,继而调用其的方法。 public class Singleton { private Singleton(){}    //在自己内部定义自己一个实例,是不是很奇怪?    //注意这是private 只供内部调用    private static Singleton instance = new Singleton();    //这里提供了一个供外部访问本class的静态方法,可以直接访问      public static Singleton getInstance() {      return instance;       } } 第二种形式: public class Singleton {   private static Singleton instance = null;   public static synchronized Singleton getInstance() {   //这个方法比上面有所改进,不用每次都进行生成对象,只是第一次        //使用时生成实例,提高了效率!   if (instance==null)     instance=new Singleton(); return instance;   } } 其他形式: 定义一个类,它的构造函数为private的,所有方法为static的。 一般认为第一种形式要更加安全些 49、Java的接口和C++的虚类的相同和不同处。 由于Java不支持多继承,而有可能某个类或对象要使用分别在几个类或对象里面的方法或属性,现有的单继承机制就不能满足要求。与继承相比,接口有更高的灵活性,因为接口没有任何实现代码。当一个类实现了接口以后,该类要实现接口里面所有的方法和属性,并且接口里面的属性在默认状态下面都是public static,所有方法默认情况下是public.一个类可以实现多个接口。 50、Java的异常处理机制的简单原理和应用。 当JAVA程序违反了JAVA的语义规则时,JAVA虚拟机就会将发生的错误表示为一个异常。违反语义规则包括2种情况。一种是JAVA类库内置的语义检查。例如数组下标越界,会引发IndexOutOfBoundsException;访问null的对象时会引发NullPointerException。另一种情况就是JAVA允许程序员扩展这种语义检查,程序员可以创建自己的异常,并自由选择在何时用throw关键字引发异常。所有的异常都是java.lang.Thowable的子类。 51、垃圾回收的优点和原理。并考虑2种回收机制。 Java语言一个显著的特点就是引入了垃圾回收机制,使c++程序员最头疼的内存管理的问题迎刃而解,它使得Java程序员在编写程序的时候不再需要考虑内存管理。由于有个垃圾回收机制,Java的对象不再有"作用域"的概念,只有对象的引用才有"作用域"。垃圾回收可以有效的防止内存泄露,有效的使用可以使用的内存。垃圾回收器通常是作为一个单独的低级别的线程运行,不可预知的情况下对内存堆已经死亡的或者长时间没有使用的对象进行清楚和回收,程序员不能实时的调用垃圾回收器对某个对象或所有对象进行垃圾回收。回收机制有分代复制垃圾回收和标记垃圾回收,增量垃圾回收。 52、请说出你所知道的线程同步的方法。 wait():使一个线程处于等待状态,并且释放所持有的对象的lock。 sleep():使一个正在运行的线程处于睡眠状态,是一个静态方法,调用此方法要捕捉InterruptedException异常。 notify():唤醒一个处于等待状态的线程,注意的是在调用此方法的时候,并不能确切的唤醒某一个等待状态的线程,而是由JVM确定唤醒哪个线程,而且不是按优先级。 Allnotity():唤醒所有处入等待状态的线程,注意并不是给所有唤醒线程一个对象的锁,而是让它们竞争。 53、你所知道的集合类都有哪些?主要方法? 最常用的集合类是 List 和 Map。 List 的具体实现包括 ArrayList 和 Vector,它们是可变大小的列表,比较适合构建、存储和操作任何类型对象的元素列表。 List 适用于按数值索引访问元素的情形。 Map 提供了一个更通用的元素存储方法。 Map 集合类用于存储元素对(称作"键"和"值"),其每个键映射到一个值。 54、描述一下JVM加载class文件的原理机制? JVM类的装载是由ClassLoader和它的子类来实现的,Java ClassLoader 是一个重要的Java运行时系统组件。它负责在运行时查找和装入类文件的类。 55、char型变量能不能存贮一个文汉字?为什么? 能够定义成为一个文的,因为java以unicode编码,一个char占16个字节,所以放一个文是没问题的 56、多线程有几种实现方法,都是什么?同步有几种实现方法,都是什么? 多线程有两种实现方法,分别是继承Thread类与实现Runnable接口 同步的实现方面有两种,分别是synchronized,wait与notify 57、JSP的内置对象及方法。 request表示HttpServletRequest对象。它包含了有关浏览器请求的信息,并且提供了几个用于获取cookie, header, 和session数据的有用的方法。 response表示HttpServletResponse对象,并提供了几个用于设置送回 浏览器的响应的方法(如cookies,头信息等) out对象是javax.jsp.JspWriter的一个实例,并提供了几个方法使你能用于向浏览器回送输出结果。 pageContext表示一个javax.servlet.jsp.PageContext对象。它是用于方便存取各种范围的名字空间、servlet相关的对象的API,并且包装了通用的servlet相关功能的方法。 session表示一个请求的javax.servlet.http.HttpSession对象。Session可以存贮用户的状态信息 applicaton 表示一个javax.servle.ServletContext对象。这有助于查找有关servlet引擎和servlet环境的信息 config表示一个javax.servlet.ServletConfig对象。该对象用于存取servlet实例的初始化参数。 page表示从该页面产生的一个servlet实例 58、线程的基本概念、线程的基本状态以及状态之间的关系 线程指在程序执行过程,能够执行程序代码的一个执行单位,每个程序至少都有一个线程,也就是程序本身。 Java的线程有四种状态分别是:运行、就绪、挂起、结束。 59、JSP的常用指令 isErrorPage(是否能使用Exception对象),isELIgnored(是否忽略表达式) 60、什么情况下调用doGet()和doPost()? Jsp页面的form标签里的method属性为get时调用doGet(),为post时调用doPost()。 61、servlet的生命周期 web容器加载servlet,生命周期开始。通过调用servlet的init()方法进行servlet的初始化。通过调用service()方法实现,根据请求的不同调用不同的do***()方法。结束服务,web容器调用servlet的destroy()方法。 62、如何现实servlet的单线程模式 63、页面间对象传递的方法 request,session,application,cookie等 64、JSP和Servlet有哪些相同点和不同点,他们之间的联系是什么? JSP是Servlet技术的扩展,本质上是Servlet的简易方式,更强调应用的外表表达。JSP编译后是"类servlet"。Servlet和JSP最主要的不同点在于,Servlet的应用逻辑是在Java文件,并且完全从表示层的HTML里分离开来。而JSP的情况是Java和HTML可以组合成一个扩展名为.jsp的文件。JSP侧重于视图,Servlet主要用于控制逻辑。 65、四种会话跟踪技术 会话作用域ServletsJSP 页面描述 page否是代表与一个页面相关的对象和属性。一个页面由一个编译好的 Java servlet 类(可以带有任何的 include 指令,但是没有 include 动作)表示。这既包括 servlet 又包括被编译成 servlet 的 JSP 页面 request是是代表与 Web 客户机发出的一个请求相关的对象和属性。一个请求可能跨越多个页面,涉及多个 Web 组件(由于 forward 指令和 include 动作的关系) session是是代表与用于某个 Web 客户机的一个用户体验相关的对象和属性。一个 Web 会话可以也经常会跨越多个客户机请求 application是是代表与整个 Web 应用程序相关的对象和属性。这实质上是跨越整个 Web 应用程序,包括多个页面、请求和会话的一个全局作用域 66、Request对象的主要方法: setAttribute(String name,Object):设置名字为name的request的参数值 getAttribute(String name):返回由name指定的属性值 getAttributeNames():返回request对象所有属性的名字集合,结果是一个枚举的实例 getCookies():返回客户端的所有Cookie对象,结果是一个Cookie数组 getCharacterEncoding():返回请求的字符编码方式 getContentLength():返回请求的Body的长度 getHeader(String name):获得HTTP协议定义的文件头信息 getHeaders(String name):返回指定名字的request Header的所有值,结果是一个枚举的实例 getHeaderNames():返回所以request Header的名字,结果是一个枚举的实例 getInputStream():返回请求的输入流,用于获得请求的数据 getMethod():获得客户端向服务器端传送数据的方法 getParameter(String name):获得客户端传送给服务器端的有name指定的参数值 getParameterNames():获得客户端传送给服务器端的所有参数的名字,结果是一个枚举的实例 getParameterValues(String name):获得有name指定的参数的所有值 getProtocol():获取客户端向服务器端传送数据所依据的协议名称 getQueryString():获得查询字符串 getRequestURI():获取发出请求字符串的客户端地址 getRemoteAddr():获取客户端的IP地址 getRemoteHost():获取客户端的名字 getSession([Boolean create]):返回和请求相关Session getServerName():获取服务器的名字 getServletPath():获取客户端所请求的脚本文件的路径 getServerPort():获取服务器的端口号 removeAttribute(String name):删除请求的一个属性 67、J2EE是技术还是平台还是框架? J2EE本身是一个标准,一个为企业分布式应用的开发提供的标准平台。 J2EE也是一个框架,包括JDBC、JNDI、RMI、JMS、EJB、JTA等技术。 68、我们在web应用开发过程经常遇到输出某种编码的字符,如iso8859-1等,如何输出一个某种编码的字符串? Public String translate (String str) { String tempStr = ""; try { tempStr = new String(str.getBytes("ISO-8859-1"), "GBK"); tempStr = tempStr.trim(); } catch (Exception e) { System.err.println(e.getMessage()); } return tempStr; } 69、简述逻辑操作(&,|,^)与条件操作(&&,||)的区别。 区别主要答两点:a.条件操作只能操作布尔型的,而逻辑操作不仅可以操作布尔型,而且可以操作数值型 b.逻辑操作不会产生短路 70、XML文档定义有几种形式?它们之间有何本质区别?解析XML文档有哪几种方式? a: 两种形式 dtd schema,b: 本质区别:schema本身是xml的,可以被XML解析器解析(这也是从DTD上发展schema的根本目的),c:有DOM,SAX,STAX等 DOM:处理大型文件时其性能下降的非常厉害。这个问题是由DOM的树结构所造成的,这种结构占用的内存较多,而且DOM必须在解析文件之前把整个文档装入内存,适合对XML的随机访问 SAX:不现于DOM,SAX是事件驱动型的XML解析方式。它顺序读取XML文件,不需要一次全部装载整个文件。当遇到像文件开头,文档结束,或者标签开头与标签结束时,它会触发一个事件,用户通过在其回调事件写入处理代码来处理XML文件,适合对XML的顺序访问 STAX:Streaming API for XML (StAX) 71、简述synchronized和java.util.concurrent.locks.Lock的异同 ? 主要相同点:Lock能完成synchronized所实现的所有功能 主要不同点:Lock有比synchronized更精确的线程语义和更好的性能。synchronized会自动释放锁,而Lock一定要求程序员手工释放,并且必须在finally从句释放。 72、EJB的角色和三个对象 一个完整的基于EJB的分布式计算结构由六个角色组成,这六个角色可以由不同的开发商提供,每个角色所作的工作必须遵循Sun公司提供的EJB规范,以保证彼此之间的兼容性。这六个角色分别是EJB组件开发者(Enterprise Bean Provider) 、应用组合者(Application Assembler)、部署者(Deployer)、EJB 服务器提供者(EJB Server Provider)、EJB 容器提供者(EJB Container Provider)、系统管理员(System Administrator) 三个对象是Remote(Local)接口、Home(LocalHome)接口,Bean类 73、EJB容器提供的服务 主要提供声明周期管理、代码产生、持续性管理、安全、事务管理、锁和并发行管理等服务。 74、EJB规范规定EJB禁止的操作有哪些? 1.不能操作线程和线程API(线程API指非线程对象的方法如notify,wait等),2.不能操作awt,3.不能实现服务器功能,4.不能对静态属生存取,5.不能使用IO操作直接存取文件系统,6.不能加载本地库.,7.不能将this作为变量和返回,8.不能循环调用。 75、remote接口和home接口主要作用 remote接口定义了业务方法,用于EJB客户端调用业务方法。 home接口是EJB工厂用于创建和移除查找EJB实例 76、bean 实例的生命周期 对于Stateless Session Bean、Entity Bean、Message Driven Bean一般存在缓冲池管理,而对于Entity Bean和Statefull Session Bean存在Cache管理,通常包含创建实例,设置上下文、创建EJB Object(create)、业务方法调用、remove等过程,对于存在缓冲池管理的Bean,在create之后实例并不从内存清除,而是采用缓冲池调度机制不断重用实例,而对于存在Cache管理的Bean则通过激活和去激活机制保持Bean的状态并限制内存实例数量。 77、EJB的激活机制 以Stateful Session Bean 为例:其Cache大小决定了内存可以同时存在的Bean实例的数量,根据MRU或NRU算法,实例在激活和去激活状态之间迁移,激活机制是当客户端调用某个EJB实例业务方法时,如果对应EJB Object发现自己没有绑定对应的Bean实例则从其去激活Bean存储(通过序列化机制存储实例)回复(激活)此实例。状态变迁前会调用对应的ejbActive和ejbPassivate方法。 78、EJB的几种类型 会话(Session)Bean ,实体(Entity)Bean 消息驱动的(Message Driven)Bean 会话Bean又可分为有状态(Stateful)和无状态(Stateless)两种 实体Bean可分为Bean管理的持续性(BMP)和容器管理的持续性(CMP)两种 79、客服端调用EJB对象的几个基本步骤 设置JNDI服务工厂以及JNDI服务地址系统属性,查找Home接口,从Home接口调用Create方法创建Remote接口,通过Remote接口调用其业务方法。 80、如何给weblogic指定大小的内存? 在启动Weblogic的脚本(位于所在Domian对应服务器目录下的startServerName),增加set MEM_ARGS=-Xms32m -Xmx200m,可以调整最小内存为32M,最大200M 81、如何设定的weblogic的热启动模式(开发模式)与产品发布模式? 可以在管理控制台修改对应服务器的启动模式为开发或产品模式之一。或者修改服务的启动文件或者commenv文件,增加set PRODUCTION_MODE=true。 82、如何启动时不需输入用户名与密码? 修改服务启动文件,增加 WLS_USER和WLS_PW项。也可以在boot.properties文件增加加密过的用户名和密码. 83、在weblogic管理制台对一个应用域(或者说是一个网站,Domain)进行jms及ejb或连接池等相关信息进行配置后,实际保存在什么文件? 保存在此Domain的config.xml文件,它是服务器的核心配置文件。 84、说说weblogic一个Domain的缺省目录结构?比如要将一个简单的helloWorld.jsp放入何目录下,然的在浏览器上就可打入http://主机:端口号//helloword.jsp就可以看到运行结果了? 又比如这其用到了一个自己写的javaBean该如何办? Domain目录服务器目录applications,将应用目录放在此目录下将可以作为应用访问,如果是Web应用,应用目录需要满足Web应用目录要求,jsp文件可以直接放在应用目录,Javabean需要放在应用目录的WEB-INF目录的classes目录,设置服务器的缺省应用将可以实现在浏览器上无需输入应用名。 85、在weblogic发布ejb需涉及到哪些配置文件 不同类型的EJB涉及的配置文件不同,都涉及到的配置文件包括ejb-jar.xml,weblogic-ejb-jar.xmlCMP实体Bean一般还需要weblogic-cmp-rdbms-jar.xml 86、如何在weblogic进行ssl配置与客户端的认证配置或说说j2ee(标准)进行ssl的配置 缺省安装使用DemoIdentity.jks和DemoTrust.jks KeyStore实现SSL,需要配置服务器使用Enable SSL,配置其端口,在产品模式下需要从CA获取私有密钥和数字证书,创建identity和trust keystore,装载获得的密钥和数字证书。可以配置此SSL连接是单向还是双向的。 87、如何查看在weblogic已经发布的EJB? 可以使用管理控制台,在它的Deployment可以查看所有已发布的EJB 88、CORBA是什么?用途是什么? CORBA 标准是公共对象请求代理结构(Common Object Request Broker Architecture),由对象管理组织 (Object Management Group,缩写为 OMG)标准化。它的组成是接口定义语言(IDL), 语言绑定(binding:也译为联编)和允许应用程序间互操作的协议。 其目的为:用不同的程序设计语言书写在不同的进程运行,为不同的操作系统开发。 89、说说你所熟悉或听说过的j2ee的几种常用模式?及对设计模式的一些看法 Session Facade Pattern:使用SessionBean访问EntityBean Message Facade Pattern:实现异步调用 EJB Command Pattern:使用Command JavaBeans取代SessionBean,实现轻量级访问 Data Transfer Object Factory:通过DTO Factory简化EntityBean数据提供特性 Generic Attribute Access:通过AttibuteAccess接口简化EntityBean数据提供特性 Business Interface:通过远程(本地)接口和Bean类实现相同接口规范业务逻辑一致性 EJB架构的设计好坏将直接影响系统的性能、可扩展性、可维护性、组件可重用性及开发效率。项目越复杂,项目队伍越庞大则越能体现良好设计的重要性。 90、说说在weblogic开发消息Bean时的persistent与non-persisten的差别 persistent方式的MDB可以保证消息传递的可靠性,也就是如果EJB容器出现问题而JMS服务器依然会将消息在此MDB可用的时候发送过来,而non-persistent方式的消息将被丢弃。 91、Servlet执行时一般实现哪几个方法? public void init(ServletConfig config) public ServletConfig getServletConfig() public String getServletInfo() public void service(ServletRequest request,ServletResponse response) public void destroy() 92、j2ee常用的设计模式?说明工厂模式。 Java的23种设计模式: Factory(工厂模式), Builder(建造模式), Factory Method(工厂方法模式), Prototype(原始模型模式),Singleton(单例模式), Facade(门面模式), Adapter(适配器模式), Bridge(桥梁模式), Composite(合成模式), Decorator(装饰模式), Flyweight(享元模式), Proxy(代理模式), Command(命令模式), Interpreter(解释器模式), Visitor(访问者模式), Iterator(迭代子模式), Mediator(调停者模式), Memento(备忘录模式), Observer(观察者模式), State(状态模式), Strategy(策略模式), Template Method(模板方法模式), Chain Of Responsibleity(责任链模式) 工厂模式:工厂模式是一种经常被使用到的模式,根据工厂模式实现的类可以根据提供的数据生成一组类某一个类的实例,通常这一组类有一个公共的抽象父类并且实现了相同的方法,但是这些方法针对不同的数据进行了不同的操作。首先需要定义一个基类,该类的子类通过不同的方法实现了基类的方法。然后需要定义一个工厂类,工厂类可以根据条件生成不同的子类实例。当得到子类的实例后,开发人员可以调用基类的方法而不必考虑到底返回的是哪一个子类的实例。 93、EJB需直接实现它的业务接口或Home接口吗,请简述理由。 远程接口和Home接口不需要直接实现,他们的实现代码是由服务器产生的,程序运行对应实现类会作为对应接口类型的实例被使用。 94、排序都有哪几种方法?请列举。用JAVA实现一个快速排序。 排序的方法有:插入排序(直接插入排序、希尔排序),交换排序(冒泡排序、快速排序),选择排序(直接选择排序、堆排序),归并排序,分配排序(箱排序、基数排序) 快速排序的伪代码。 / /使用快速排序方法对a[ 0 :n- 1 ]排序 从a[ 0 :n- 1 ]选择一个元素作为m i d d l e,该元素为支点 把余下的元素分割为两段left 和r i g h t,使得l e f t的元素都小于等于支点,而right 的元素都大于等于支点 递归地使用快速排序方法对left 进行排序 递归地使用快速排序方法对right 进行排序 所得结果为l e f t + m i d d l e + r i g h t 95、请对以下在J2EE常用的名词进行解释(或简单描述) web容器:给处于其的应用程序组件(JSP,SERVLET)提供一个环境,使JSP,SERVLET直接更容器的环境变量接口交互,不必关注其它系统问题。主要有WEB服务器来实现。例如:TOMCAT,WEBLOGIC,WEBSPHERE等。该容器提供的接口严格遵守J2EE规范的WEB APPLICATION 标准。我们把遵守以上标准的WEB服务器就叫做J2EE的WEB容器。 EJB容器:Enterprise java bean 容器。更具有行业领域特色。他提供给运行在其的组件EJB各种管理功能。只要满足J2EE规范的EJB放入该容器,马上就会被容器进行高效率的管理。并且可以通过现成的接口来获得系统级别的服务。例如邮件服务、事务管理。 JNDI:(Java Naming & Directory Interface)JAVA命名目录服务。主要提供的功能是:提供一个目录系统,让其它各地的应用程序在其上面留下自己的索引,从而满足快速查找和定位分布式应用程序的功能。 JMS:(Java Message Service)JAVA消息服务。主要实现各个应用程序之间的通讯。包括点对点和广播。 JTA:(Java Transaction API)JAVA事务服务。提供各种分布式事务服务。应用程序只需调用其提供的接口即可。 JAF:(Java Action FrameWork)JAVA安全认证框架。提供一些安全控制方面的框架。让开发者通过各种部署和自定义实现自己的个性安全控制策略。 RMI/IIOP:(Remote Method Invocation /internet对象请求介协议)他们主要用于通过远程调用服务。例如,远程有一台计算机上运行一个程序,它提供股票分析服务,我们可以在本地计算机上实现对其直接调用。当然这是要通过一定的规范才能在异构的系统之间进行通信。RMI是JAVA特有的。 96、JAVA语言如何进行异常处理,关键字:throws,throw,try,catch,finally分别代表什么意义?在try块可以抛出异常吗? Java通过面向对象的方法进行异常处理,把各种不同的异常进行分类,并提供了良好的接口。在Java,每个异常都是一个对象,它是Throwable类或其它子类的实例。当一个方法出现异常后便抛出一个异常对象,该对象包含有异常信息,调用这个对象的方法可以捕获到这个异常并进行处理。Java的异常处理是通过5个关键词来实现的:try、catch、throw、throws和finally。一般情况下是用try来执行一段程序,如果出现异常,系统会抛出(throws)一个异常,这时候你可以通过它的类型来捕捉(catch)它,或最后(finally)由缺省处理器来处理。 用try来指定一块预防所有"异常"的程序。紧跟在try程序后面,应包含一个catch子句来指定你想要捕捉的"异常"的类型。 throw语句用来明确地抛出一个"异常"。 throws用来标明一个成员函数可能抛出的各种"异常"。 Finally为确保一段代码不管发生什么"异常"都被执行一段代码。 可以在一个成员函数调用的外面写一个try语句,在这个成员函数内部写另一个try语句保护其他代码。每当遇到一个try语句,"异常"的框架就放到堆栈上面,直到所有的try语句都完成。如果下一级的try语句没有对某种"异常"进行处理,堆栈就会展开,直到遇到有处理这种"异常"的try语句。 97、一个".java"源文件是否可以包括多个类(不是内部类)?有什么限制? 可以。必须只有一个类名与文件名相同。 98、MVC的各个部分都有那些技术来实现?如何实现? MVC是Model-View-Controller的简写。"Model" 代表的是应用的业务逻辑(通过JavaBean,EJB组件实现), "View" 是应用的表示面(由JSP页面产生),"Controller" 是提供应用的处理过程控制(一般是一个Servlet),通过这种设计模型把应用逻辑,处理过程和显示逻辑分成不同的组件实现。这些组件可以进行交互和重用。 99、java有几种方法可以实现一个线程?用什么关键字修饰同步方法? stop()和suspend()方法为何不推荐使用? 有两种实现方法,分别是继承Thread类与实现Runnable接口 用synchronized关键字修饰同步方法 反对使用stop(),是因为它不安全。它会解除由线程获取的所有锁定,而且如果对象处于一种不连贯状态,那么其他线程能在那种状态下检查和修改它们。结果很难检查出真正的问题所在。suspend()方法容易发生死锁。调用suspend()的时候,目标线程会停下来,但却仍然持有在这之前获得的锁定。此时,其他任何线程都不能访问锁定的资源,除非被"挂起"的线程恢复运行。对任何线程来说,如果它们想恢复目标线程,同时又试图使用任何一个锁定的资源,就会造成死锁。所以不应该使用suspend(),而应在自己的Thread类置入一个标志,指出线程应该活动还是挂起。若标志指出线程应该挂起,便用wait()命其进入等待状态。若标志指出线程应当恢复,则用一个notify()重新启动线程。 100、java有几种类型的流?JDK为每种类型的流提供了一些抽象类以供继承,请说出他们分别是哪些类? 字节流,字符流。字节流继承于InputStream OutputStream,字符流继承于InputStreamReader OutputStreamWriter。在java.io包还有许多其他的流,主要是为了提高性能和使用方便。 101、java会存在内存泄漏吗,请简单描述。 会。如:int i,i2; return (i-i2); //when i为足够大的正数,i2为足够大的负数。结果会造成溢位,导致错误。 102、java实现多态的机制是什么? 方法的重写Overriding和重载Overloading是Java多态性的不同表现。重写Overriding是父类与子类之间多态性的一种表现,重载Overloading是一个类多态性的一种表现。 103、垃圾回收器的基本原理是什么?垃圾回收器可以马上回收内存吗?有什么办法主动通知虚拟机进行垃圾回收? 对于GC来说,当程序员创建对象时,GC就开始监控这个对象的地址、大小以及使用情况。通常,GC采用有向图的方式记录和管理堆(heap)的所有对象。通过这种方式确定哪些对象是"可达的",哪些对象是"不可达的"。当GC确定一些对象为"不可达"时,GC就有责任回收这些内存空间。可以。程序员可以手动执行System.gc(),通知GC运行,但是Java语言规范并不保证GC一定会执行。 104、静态变量和实例变量的区别? static i = 10; //常量 class A a; a.i =10;//可变 105、什么是java序列化,如何实现java序列化? 序列化就是一种用来处理对象流的机制,所谓对象流也就是将对象的内容进行流化。可以对流化后的对象进行读写操作,也可将流化后的对象传输于网络之间。序列化是为了解决在对对象流进行读写操作时所引发的问题。 序列化的实现:将需要被序列化的类实现Serializable接口,该接口没有需要实现的方法,implements Serializable只是为了标注该对象是可被序列化的,然后使用一个输出流(如:FileOutputStream)来构造一个ObjectOutputStream(对象流)对象,接着,使用ObjectOutputStream对象的writeObject(Object obj)方法就可以将参数为obj的对象写出(即保存其状态),要恢复的话则用输入流。 106、是否可以从一个static方法内部发出对非static方法的调用? 不可以,如果其包含对象的method();不能保证对象初始化. 107、写clone()方法时,通常都有一行代码,是什么? Clone 有缺省行为,super.clone();他负责产生正确大小的空间,并逐位复制。 108、在JAVA,如何跳出当前的多重嵌套循环? 用break; return 方法。 109、List、MapSet三个接口,存取元素时,各有什么特点? List 以特定次序来持有元素,可有重复元素。Set 无法拥有重复元素,内部排序。Map 保存key-value值,value可多值。 110、J2EE是什么? J2EE是Sun公司提出的多层(multi-diered),分布式(distributed),基于组件(component-base)的企业级应用模型(enterpriese application model).在这样的一个应用系统,可按照功能划分为不同的组件,这些组件又可在不同计算机上,并且处于相应的层次(tier)。所属层次包括客户层(clietn tier)组件,web层和组件,Business层和组件,企业信息系统(EIS)层。 111、UML方面 标准建模语言UML。用例图,静态图(包括类图、对象图和包图),行为图,交互图(顺序图,合作图),实现图。 112、说出一些常用的类,包,接口,请各举5个 常用的类:BufferedReader BufferedWriter FileReader FileWirter String Integer 常用的包:java.lang java.awt java.io java.util java.sql 常用的接口:Remote List Map Document NodeList 113、开发都用到了那些设计模式?用在什么场合? 每个模式都描述了一个在我们的环境不断出现的问题,然后描述了该问题的解决方案的核心。通过这种方式,你可以无数次地使用那些已有的解决方案,无需在重复相同的工作。主要用到了MVC的设计模式。用来开发JSP/Servlet或者J2EE的相关应用。简单工厂模式等。 114、jsp有哪些动作?作用分别是什么? JSP共有以下6种基本动作 jsp:include:在页面被请求的时候引入一个文件。 jsp:useBean:寻找或者实例化一个JavaBean。 jsp:setProperty:设置JavaBean的属性。 jsp:getProperty:输出某个JavaBean的属性。 jsp:forward:把请求转到一个新的页面。 jsp:plugin:根据浏览器类型为Java插件生成OBJECT或EMBED标记。 115、Anonymous Inner Class (匿名内部类) 是否可以extends(继承)其它类,是否可以implements(实现)interface(接口)? 可以继承其他类或完成其他接口,在swing编程常用此方式。 116、应用服务器与WEB SERVER的区别? 应用服务器:Weblogic、Tomcat、Jboss WEB SERVER:IIS、 Apache 117、BS与CS的联系与区别。 C/S是Client/Server的缩写。服务器通常采用高性能的PC、工作站或小型机,并采用大型数据库系统,如Oracle、Sybase、Informix或 SQL Server。客户端需要安装专用的客户端软件。 B/S是Brower/Server的缩写,客户机上只要安装一个浏览器(Browser),如Netscape Navigator或Internet Explorer,服务器安装Oracle、Sybase、Informix或 SQL Server等数据库。在这种结构下,用户界面完全通过WWW浏览器实现,一部分事务逻辑在前端实现,但是主要事务逻辑在服务器端实现。浏览器通过Web Server 同数据库进行数据交互。 C/S 与 B/S 区别: 1.硬件环境不同:   C/S 一般建立在专用的网络上, 小范围里的网络环境, 局域网之间再通过专门服务器提供连接和数据交换服务.   B/S 建立在广域网之上的, 不必是专门的网络硬件环境,例与电话上网, 租用设备. 信息自己管理. 有比C/S更强的适应范围, 一般只要有操作系统和浏览器就行 2.对安全要求不同   C/S 一般面向相对固定的用户群, 对信息安全的控制能力很强. 一般高度机密的信息系统采用C/S 结构适宜. 可以通过B/S发布部分可公开信息.   B/S 建立在广域网之上, 对安全的控制能力相对弱, 可能面向不可知的用户。 3.对程序架构不同   C/S 程序可以更加注重流程, 可以对权限多层次校验, 对系统运行速度可以较少考虑.   B/S 对安全以及访问速度的多重的考虑, 建立在需要更加优化的基础之上. 比C/S有更高的要求 B/S结构的程序架构是发展的趋势, 从MS的.Net系列的BizTalk 2000 Exchange 2000等, 全面支持网络的构件搭建的系统. SUN 和IBM推的JavaBean 构件技术等,使 B/S更加成熟. 4.软件重用不同   C/S 程序可以不可避免的整体性考虑, 构件的重用性不如在B/S要求下的构件的重用性好.   B/S 对的多重结构,要求构件相对独立的功能. 能够相对较好的重用.就入买来的餐桌可以再利用,而不是做在墙上的石头桌子 5.系统维护不同   C/S 程序由于整体性, 必须整体考察, 处理出现的问题以及系统升级. 升级难. 可能是再做一个全新的系统   B/S 构件组成,方面构件个别的更换,实现系统的无缝升级. 系统维护开销减到最小.用户从网上自己下载安装就可以实现升级. 6.处理问题不同   C/S 程序可以处理用户面固定, 并且在相同区域, 安全要求高需求, 与操作系统相关. 应该都是相同的系统   B/S 建立在广域网上, 面向不同的用户群, 分散地域, 这是C/S无法作到的. 与操作系统平台关系最小. 7.用户接口不同   C/S 多是建立的Window平台上,表现方法有限,对程序员普遍要求较高   B/S 建立在浏览器上, 有更加丰富和生动的表现方式与用户交流. 并且大部分难度减低,减低开发成本. 8.信息流不同   C/S 程序一般是典型的央集权的机械式处理, 交互性相对低   B/S 信息流向可变化, B-B B-C B-G等信息、流向的变化, 更像交易心。 118、LINUX下线程,GDI类的解释。 LINUX实现的就是基于核心轻量级进程的"一对一"线程模型,一个线程实体对应一个核心轻量级进程,而线程之间的管理在核外函数库实现。 GDI类为图像设备编程接口类库。 119、STRUTS的应用(如STRUTS架构) Struts是采用Java Servlet/JavaServer Pages技术,开发Web应用程序的开放源码的framework。 采用Struts能开发出基于MVC(Model-View-Controller)设计模式的应用构架。 Struts有如下的主要功能: 一.包含一个controller servlet,能将用户的请求发送到相应的Action对象。 二.JSP自由tag库,并且在controller servlet提供关联支持,帮助开发员创建交互式表单应用。 三.提供了一系列实用对象:XML处理、通过Java reflection APIs自动处理JavaBeans属性、国际化的提示和消息。 120、Jdo是什么? JDO是Java对象持久化的新的规范,为java data object的简称,也是一个用于存取某种数据仓库的对象的标准化API。JDO提供了透明的对象存储,因此对开发人员来说,存储数据对象完全不需要额外的代码(如JDBC API的使用)。这些繁琐的例行工作已经转移到JDO产品提供商身上,使开发人员解脱出来,从而集时间和精力在业务逻辑上。另外,JDO很灵活,因为它可以在任何数据底层上运行。JDBC只是面向关系数据库(RDBMS)JDO更通用,提供到任何数据底层的存储功能,比如关系数据库、文件、XML以及对象数据库(ODBMS)等等,使得应用可移植性更强。 121、内部类可以引用他包含类的成员吗?有没有什么限制? 一个内部类对象可以访问创建它的外部类对象的内容 122、WEB SERVICE名词解释。JSWDL开发包的介绍。JAXP、JAXM的解释。SOAP、UDDI,WSDL解释。 Web ServiceWeb Service是基于网络的、分布式的模块化组件,它执行特定的任务,遵守具体的技术规范,这些规范使得Web Service能与其他兼容的组件进行互操作。 JAXP(Java API for XML Parsing) 定义了在Java使用DOM, SAX, XSLT的通用的接口。这样在你的程序你只要使用这些通用的接口,当你需要改变具体的实现时候也不需要修改代码。 JAXM(Java API for XML Messaging) 是为SOAP通信提供访问方法和传输机制的API。 WSDL是一种 XML 格式,用于将网络服务描述为一组端点,这些端点对包含面向文档信息或面向过程信息的消息进行操作。这种格式首先对操作和消息进行抽象描述,然后将其绑定到具体的网络协议和消息格式上以定义端点。相关的具体端点即组合成为抽象端点(服务)。 SOAP即简单对象访问协议(Simple Object Access Protocol),它是用于交换XML编码信息的轻量级协议。 UDDI 的目的是为电子商务建立标准;UDDI是一套基于Web的、分布式的、为Web Service提供的、信息注册心的实现标准规范,同时也包含一组使企业能将自身提供的Web Service注册,以使别的企业能够发现的访问协议的实现标准。 JAVA代码查错 1. abstract class Name { private String name; public abstract boolean isStupidName(String name) {} } 大侠们,这有何错误? 答案: 错。abstract method必须以分号结尾,且不带花括号。 2. public class Something { void doSomething () { private String s = ""; int l = s.length(); } } 有错吗? 答案: 错。局部变量前不能放置任何访问修饰符 (private,public,和protected)。final可以用来修饰局部变量 (final如同abstract和strictfp,都是非访问修饰符,strictfp只能修饰class和method而非variable)。 3. abstract class Something { private abstract String doSomething (); } 这好像没什么错吧? 答案: 错。abstract的methods不能以private修饰。abstract的methods就是让子类implement(实现)具体细节的,怎么可以用private把abstract method封锁起来呢? (同理,abstract method前不能加final)。 4. public class Something { public int addOne(final int x) { return ++x; } } 这个比较明显。 答案: 错。int x被修饰成final,意味着x不能在addOne method被修改。 5. public class Something { public static void main(String[] args) { Other o = new Other(); new Something().addOne(o); } public void addOne(final Other o) { o.i++; } } class Other { public int i; } 和上面的很相似,都是关于final的问题,这有错吗? 答案: 正确。在addOne method,参数o被修饰成final。如果在addOne method里我们修改了o的reference (比如: o = new Other();),那么如同上例这题也是错的。但这里修改的是o的member vairable (成员变量),而o的reference并没有改变。 6. class Something { int i; public void doSomething() { System.out.println("i = " + i); } } 有什么错呢? 看不出来啊。 答案: 正确。输出的是"i = 0"。int i属於instant variable (实例变量,或叫成员变量)。instant variable有default value。int的default value是0。 7. class Something { final int i; public void doSomething() { System.out.println("i = " + i); } } 和上面一题只有一个地方不同,就是多了一个final。这难道就错了吗? 答案: 错。final int i是个final的instant variable (实例变量,或叫成员变量)。final的instant variable没有default value,必须在constructor (构造器)结束之前被赋予一个明确的值。可以修改为"final int i = 0;"。 8. public class Something { public static void main(String[] args) { Something s = new Something(); System.out.println("s.doSomething() returns " + doSomething()); } public String doSomething() { return "Do something ..."; } } 看上去很完美。 答案: 错。看上去在main里call doSomething没有什么问题,毕竟两个methods都在同一个class里。但仔细看,main是static的。static method不能直接call non-static methods。可改成"System.out.println("s.doSomething() returns " + s.doSomething());"。同理,static method不能访问non-static instant variable。 9. 此处,Something类的文件名叫OtherThing.java class Something { private static void main(String[] something_to_do) { System.out.println("Do something ..."); } } 这个好像很明显。 答案: 正确。从来没有人说过Java的Class名字必须和其文件名相同。但public class的名字必须和文件名相同。 10. interface A{ int x = 0; } class B{ int x =1; } class C extends B implements A { public void pX(){ System.out.println(x); } public static void main(String[] args) { new C().pX(); } } 答案:错误。在编译时会发生错误(错误描述不同的JVM有不同的信息,意思就是未明确的x调用,两个x都匹配(就象在同时import java.util和java.sql两个包时直接声明Date一样)。对于父类的变量,可以用super.x来明确,而接口的属性默认隐含为 public static final.所以可以通过A.x来明确。 11. interface Playable { void play(); } interface Bounceable { void play(); } interface Rollable extends Playable, Bounceable { Ball ball = new Ball("PingPang"); } class Ball implements Rollable { private String name; public String getName() { return name; } public Ball(String name) { this.name = name; } public void play() { ball = new Ball("Football"); System.out.println(ball.getName()); } } 这个错误不容

13,874

社区成员

发帖
与我相关
我的任务
社区描述
C++ Builder相关内容讨论区
社区管理员
  • 基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧