Java_note
android开发与架构设计解析

f. 在Target面板的Automatic中勾选相应的AVD, 如果没有可用的AVD的话,你需要点击右下角的 Manager…,然后新建相应的AVD。如下图所示:
g. 然后点Run按钮即可,运行成功的话会有 Android的模拟器界面,如下图所示:
相关参数的说明:
A. Project Name: 包含这个项目的文件夹的名称。 B. Package Name: 包名,遵循JAVA规范,用包名来区 分不同的类是很重要的,我用的是helloworld.test。 C. Activity Name: 这是项目的主类名,这个类将会是 Android的Activity类的子类。一个Activity类是一 个简单的启动程序和控制程序的类。它可以根据需 要创建界面,但不是必须的。 D. Application Name: 一个易读的标题在你的应用程序 上。 E. 在"选择栏"的 "Use default location" 选项,允许你 选择一个已存在的项目。
安装完成之后,可以在检查JDK是否安装成功。 打开cmd窗口,输入java –version 查看JDK的版本信 息。出现类似下面的画面表示安装成功了:
1.2、 Eclipse安装 如果你还没有Eclipse的话,可以先去下载,下载 如下图所示的Eclipse IDE for Java Developers (92M)的win 32bit版:解压之后既可使用。
确定返回后,在work with后的下拉列表中 选择我们刚才添加的 ADT,我们会看到下 面出有Developer Tools,展开它会有 Android DDMS 和Android Development Tool,勾选他们。 如右图所示: 完成之后: » 选择Window > Preferences... » 在左边的面板选择Android,然后在右侧 点击Browse...并选中SDK路径,本机为: D:\AndroidDevelop\android-sdkwindows » 点击Apply、OK。配置完成。
技术-Java防反编译技术

Java防反编译技术1简介1.1 Java软件面临的挑战目前,由于黑客的频繁活动,使得Java类文件面临着反编译的挑战。
有一些工具能够对Java 源代码进行反工程,其结果甚至以比普通Java文件更可读的方式, 尽管普通的Java文件(由于代码风格不同)有注释。
许可证和软件过期对于用户们来说将变得无用。
因此,防止软件被反编译或使得反编译的结果变得无意义对于Java来说非常重要。
一个Java类文件不一定非要存储在一个真正的文件里;它可以存在存贮器缓冲区,或从一个网络流获得。
尽管防火墙和网络协议如TCP/IP有安全策略,黑客仍能打破访问限制获取一些类。
尽管这些类能被混淆,他们(黑客)能够一步一步地分析和猜出每个指令的目的。
如果这些代码是关键技术部分,例如是大产品的许可证或时间期满部分,反编译和分析指令的努力似乎很值得。
如果这些关键类被隐藏或被一个关键字加密,黑客的非法入侵就很困难了。
而且,未认证的软件复制对智能产权是普遍的攻击。
还没有一个较好的通用方案来解决这类问题。
目前关于JA V A程序的加密方式不外乎JA V A混淆处理(Obfuscator)和运用ClassLoader 方法进行加密处理这两种方式(其他的方式亦有,但大多是这两种的延伸和变异)。
1.2 混淆处理关于JA V A程序的加密方式,一直以来都是以JA V A混淆处理(Obfuscator)为主。
这方面的研究结果也颇多,既有混淆器(如现在大名鼎鼎的JODE,SUN开发的JADE),也有针对反编译器的"炸弹"(如针对反编译工具Mocha的"炸弹" Crema和HoseMocha)。
混淆器,从其字面上,我们就可以知道它是通过混淆处理JA V A代码,具体的说,就是更换变量名,函数名,甚至类名等方法使其反编译出来的代码变得不可理解。
它的目的是:让程序无法被自动反编译,就算被反编译成功,也不容易被程序员阅读理解其实这只是做到了视觉上的处理,其业务逻辑却依然不变,加以耐心,仍是可以攻破的,如果用在用户身份验证等目的上,完全可以找到身份验证算法而加以突破限制。
大学java笔试题库及答案

大学java笔试题库及答案1. 以下哪个选项是Java语言的特点?A. 面向过程B. 面向对象C. 面向组件D. 面向服务答案:B2. Java中,用于定义类的关键字是:A. classB. publicC. privateD. interface答案:A3. 在Java中,下列哪个关键字用于声明一个方法?A. classB. methodC. functionD. void答案:D4. Java中,下列哪个关键字用于声明一个私有变量?A. publicB. privateC. protectedD. static答案:B5. 在Java中,下列哪个关键字用于声明一个静态变量?A. publicB. privateC. protectedD. static答案:D6. Java中,下列哪个关键字用于声明一个接口?A. classB. interfaceC. abstractD. final答案:B7. 在Java中,下列哪个关键字用于声明一个抽象类?A. abstractB. finalC. staticD. interface答案:A8. Java中,下列哪个关键字用于实现多态性?A. extendsB. implementsC. overrideD. super答案:A9. 在Java中,下列哪个关键字用于声明一个异常?A. throwB. throwsC. tryD. catch答案:B10. Java中,下列哪个关键字用于声明一个同步方法?A. synchronizedB. staticC. finalD. abstract答案:A11. 在Java中,下列哪个关键字用于声明一个内部类?A. innerB. nestedC. classD. private答案:C12. Java中,下列哪个关键字用于声明一个枚举类型?A. enumB. listC. setD. map答案:A13. 在Java中,下列哪个关键字用于声明一个泛型?A. genericB. typeC. extendsD. <>答案:D14. Java中,下列哪个关键字用于声明一个注解?A. annotationB. commentC. noteD. @interface答案:D15. 在Java中,下列哪个关键字用于声明一个线程?A. threadB. runnableC. synchronizedD. concurrent答案:B。
24点游戏的设计与实现

题目:基于Android的24点游戏的设计和实现学院:计算机科学与技术学院专业:计算机科学与技术中文摘要随着移动设备的普及以及移动设备的硬件的提升,移动设备的功能越来越完善,移动设备的系统平台也日渐火热起来。
目前国内最常见的移动开发平台有iPhone,Windows Phone以及当下正在逐步兴起的Android,目前为止国内已经有很多Android系统的用户。
在80年代流行一种数字游戏,我们称之为“24点”。
用扑克牌实现24点,就是从扑克牌中任意抽出4张(数字表示为1-13),用加、减、乘、除的方法计算得到24。
借鉴网上的多种游戏,在eclipse模拟平台环境下开发了24点游戏,该游戏可以在Android手机上运行。
程序实现由系统随机产生4张牌,玩家输入表达式,然后判断表达式是否合法且等于24,并给出可能的合法表达式。
关键词:Android eclipse 手机模拟平台 24点游戏AbstractWith the growing popularity of mobile devices and mobile device hardware upgrade, mobile devices become more perfect system platform for mobile devices are increasingly picking up. At present, the most common mobile development platform for the iPhone, Windows Phone, as well as the current is gradually emerging Android, so far the country has a lot of users of the Android system.In the 1980s a popular numbers game, which we call the "24 point". 24 points, with playing cards and poker in any out of four (numerals 1-13), with addition, subtraction, multiplication, in addition to the methods, results become 24.Learn from the online variety of games, I use the Android mobile platform designed a 24-point game, eclipse simulation platform environment to achieve the basic functions of the game program. The program randomly generated by the system of four card players enter the expression, and then determine the expression is valid and equal to 24.Key words: Android eclipse phone simulation platform 24-point game目录第一章概述 (3)1.1研究背景 (3)1.2研究内容 (3)1.3研究现状 (4)1.4论文组织 (5)第二章游戏的开发平台和基本功能 (6)2.1基本功能描述 (6)2.2运行环境需求 (6)2.3 Android开发环境 (6)第三章 24点游戏的原理与实现 (10)3.1程序模块设计 (10)3.2主要算法介绍 (11)3.2.1 游戏主算法 (11)3.2.2 计算表达式算法 (11)3.2.3给出答案的算法 (14)第四章程序运行结果 (16)第五章总结 (19)参考文献 0第一章概述1.1研究背景随着经济的日益发展,人们的生活水平有了较大的改善。
E n i g m a 算 法 详 解

成为专业程序员路上用到的各种优秀资料、神器及框架本文是鄙人工作这几年随手收集整理的一些自认为还不错的资料,成长的道理上需要积累,这么长时间了,是时候放出来分享下了,或许能帮助到你。
欢迎点赞,让更多人看到,让福利普照。
因为本文以后不会更新,但项目依旧会更新。
所以,更好的做法是,请到GitHub上Star:stanzhai-be-a-professional-programmer成为一名专业程序员的道路上,需要坚持练习、学习与积累,技术方面既要有一定的广度,更要有自己的深度。
笔者作为一位tool mad,将工作以来用到的各种优秀资料、神器及框架整理在此,毕竟好记性不如烂键盘,此项目可以作为自己的不时之需。
本人喜欢折腾,记录的东西也比较杂,各方面都会有一些,内容按重要等级排序,大家各取所需。
这里的东西会持续积累下去,欢迎Star,也欢迎发PR给我。
技术站点必看书籍大牛博客GitHub篇工具篇平台工具常用工具第三方服务爬虫相关(好玩的工具)安全相关Web服务器性能-压力测试工具-负载均衡器大数据处理-数据分析-分布式工具Web前端语言篇C游戏开发相关日志聚合,分布式日志收集RTP,实时传输协议与音视频技术站点在线学习:Coursera、edX、Udacity?-way to explore国内老牌技术社区:OSChina、博客园、CSDN、51CTO 免费的it电子书:ITeBooks - Free Download - Big Library在线学习:UdemyCrowd-sourced code mentorship. and Practicecoding with fun programming challenges - CodinGameDevStore:开发者服务商店MSDN:微软相关的官方技术集中地,主要是文档类必看书籍SICP(Structureand Interpretation of Computer Programs)深入理解计算机系统代码大全2人件人月神话软件随想录算法导论(麻省理工学院出版社)离散数学及其应用设计模式编程之美黑客与画家编程珠玑The Little SchemerSimply Scheme_Introducing_Computer_ScienceC++ PrimeEffective C++TCP-IP详解Unix 编程艺术技术的本质软件随想录计算机程序设计艺术职业篇:程序员的自我修养,程序员修炼之道,高效能程序员的修炼《精神分析引论》弗洛伊德《失控》《科技想要什么》《技术元素》凯文凯利程序开发心理学天地一沙鸥搞定:无压力工作的艺术大牛博客云风(游戏界大牛): 云风的Tian (binghe)R大【干货满满】RednaxelaFX写的文章-回答的导航帖陈皓-左耳朵耗子:酷壳 - CoolShellJeff Atwood(国外知名博主): CodingHorror阮一峰(黑客与画家译者,Web):RuanYiFeng’s Personal Website廖雪峰(他的Python、Git教-程不少人都看过):HomeGitHub篇Awesome:这是个Awesome合集,常见的资料这里面都能找到Awesome2:类似第一个Awesome杂七杂八、有用没用的Awesome合集非常不错的语言类学习资料集合:Awesomenessawesome-ios-uiawesome-android-uiAwesome-MaterialDesi gnawesome-public-datasetsawesome-AppSec(系统安全)awesome-datascience书籍资料free-programming-books中文版免费的编程中文书籍索引《程序员编程艺术—面试和算法心得》GoBooksPapersLearning)深入学习(Deep Learning)资料Docker资料合集学习使用StromHadoopInternalsSparkInternals大数据时代的数据分析与数据挖掘in DatabasesDataScience blogs日志:每个软件工程师都应该知道的有关实时数据的统一概念AndroidCode PathAndroidLearn NotesPHP类库框架,资料集合优秀项目Design开源项目Android开源项目分类汇总前端 Node.jsGuide的中文分支Angular2学习资料AngularJS应用的最佳实践和风格指南React-Native学习指南七天学会NodeJSnode.js中文资料导航Nodejs学习路线图如何学习nodejs工作,工具系统管理员工具集合ProGitNginx开发从入门到精通Google全球 IP 地址库收集整理远程工作相关的资料Colorschemes for hackers游戏开发工具集,MagicTools开发者工具箱, free-for-devGitHub秘籍Git风格指南Bast-App平台工具常用工具Mac下的神兵利器asciinema:- 免费在线作图,实时协作Origami: 次世代交互设计神器百度脑图:百度脑图第三方服务DnsPod:一个不错的只能DNS服务解析提供商DigitalOcean:海外的云主机提供商,价格便宜,磁盘是SSD的,用过一段时间整体上还可以,不过毕竟是海外的,网速比较慢。
java基础习题1

java基础习题1Day11、java是⼀门什么样的语⾔答:java是⼀门完整编程语⾔:包括⾃⼰的语法和各种java的底层⽀持。
2、java与C的区别答:(1)java中队内存的分配是动态的,采⽤⾯型对象的机制,采⽤运算符new为每个对象分配内存空间,⽽且,实际内存还会随程序运⾏情况⽽改变。
程序运⾏中java系统⾃动对内存进⾏扫描,对长期不⽤的空间作为“垃圾”进⾏收集,使得系统资源得到更充分地利⽤,程序员不必关注内存管理问题,避免了由于内存管理问题⽅⾯的差错⽽导致系统出问题。
⽽c语⾔通过malloc()和free()这两个库函数来分别实现分配内存和释放内存空间的,(2)java不是在类之外定义全局变量,⽽是在某个类中定义⼀种公⽤静态的变量来完成全局变量的功能。
(3)java不⽤goto语句,⽽是⽤try-catch-finally异常处理语句来代替goto语句处理出错的功能。
(4)java不⽀持头⽂件,⽽c和c++语⾔中都⽤头⽂件定义类的原型,全局变量,库函数等,这种采⽤头⽂件的结构使得系统的运⾏维护相当繁杂。
(5)java不⽀持宏定义,⽽是使⽤关键字fianl来定义常量,在c++中采⽤宏定义来实现常量定义,这不利于程序的可读性。
(6)java对每种数据类型都分配固定长度,具有跨平台性。
c和c++中,对于不同的平台,同⼀个数据类型分配不同的字节数,这使得c语⾔造成不可移植性。
(7)类型转换不同。
c和c++可通过指针进⾏任意的类型转换,常常带来不安全性,在java 中运⾏时系统对对象的处理要进⾏类型相容性检查,以防⽌不安全的转换。
(8)结构和联合的处理。
在c和c++中结构和联合的所有成员均为公有,这就带来了安全性问题,⽽在java中根本就不包括结构和联合,所有内容都封装在类⾥⾯。
(9)java不使⽤指针。
(10)避免平台依赖。
(11)在B/S开发⽅⾯,java要远远优于c++。
3、数据结构线性表与链表答:链表是⼀种物理存储单元上⾮连续、⾮顺序的存储结构,数据元素的逻辑顺序是通过链表中的指针链接次序实现的。
《Java》课程设计》记事本

《Java课程设计》记事本课程设计报告书目录一、设计课题二、设计目的三、操作环境四、设计场所(机房号、机器号或自己机器)五、设计过程(设计内容及主要程序模块)六、本次设计中用到的课程知识点(列出主要知识点)七、设计过程中遇到的问题及解决办法八、程序清单五、设计过程(设计内容及主要模块,不少于3000字)1.设计要求1)界面设计2)功能实现(1)文件菜单:新建、打开、保存、另存为、退出等。
(2)其中新建菜单项可以新建一个记事本程序;打开菜单项可以打开一个用户指定的文本文件,并将其内容显示在记事本的文本区域;保存和另存为菜单项可分别实现文件的保存和另存为3)编辑菜单:复制、剪切和粘贴等4)帮助菜单:软件版本信5)右键弹出快捷菜单2.总体设计1)功能模块图:图一功能模块图2)功能描述1、打开记事本。
首先是标准型的记事本,拥有文件、编辑。
格式和帮助。
如图1所示:图1标准型记事本界面2、在标准型的记事本界面中,进行的新建一个本件名字叫新记事本。
如图2记事本文件帮助新建打开保存另存为退出复制剪切粘贴编辑关于记事本右键快捷格式字体颜色图2新建记事本功能3、用打开文件打开刚刚新建的新记事本。
如图三所示。
图3—打开文件4、点击退出即可退出,如图4所示:图4—退出记事本5、点击帮助可以看到有关记事本的相关信息,其中有作者名、版本、许可条款、隐私声明等必要信息。
如图5所示:图5—帮助相关信息6、右键可实现复制、粘贴、剪切、清除等常用功能,方便用户可以快捷方便的使用记事本。
如图6所示:图6—右键功能7、编辑也可实现制、粘贴、剪切、清除等常用功能,方便用户选择自己适合的方式,自由选择方便的快捷方式使用。
如图7:图7—编辑八、程序清单package test;import java.io.File;import java.io.*;import java.awt.event.*;import java.awt.Toolkit;import java.awt.*;import javax.swing.*;import javax.swing.filechooser.*;public class Notebook extends JFrame implements ActionListener,ItemListener{ //组件创建JButton b_save,b_close; //按钮JTextArea textArea; //文本框File tempFile; //文件JPanel jp; //面板JMenu file,edit,style,help; //菜单JMenuItemf_new,f_open,f_save,f_close,f_saveas,e_copy, e_paste,e_cut,e_clear,e_selectAll,e_find,e_rep lace,s_font,s_color,h_editor,h_help; //菜单条JMenuBar jmb;JScrollPane jsp; //滚动面板JPopupMenu popUpMenu = new JPopupMenu(); //右键弹出式菜单JLabel stateBar;//标签JLabel jl,jj;JFileChooser jfc = new JFileChooser(); //文件选择JMenuItemje_copy,je_paste,je_cut,je_clear,je_selectAll,je _find,je_replace; //弹出式菜单条public Notebook(){jfc.addChoosableFileFilter(new FileNameExtensionFilter("文本文件(*.txt)","txt"));jmb = new JMenuBar();textArea = new JTextArea();jsp = new JScrollPane(textArea);file = new JMenu("文件");edit = new JMenu("编辑");style = new JMenu("格式");help = new JMenu("帮助");je_copy = new JMenuItem("复制(C) ");je_paste = new JMenuItem("粘贴(P) ");je_cut = new JMenuItem("剪切(X) ");je_clear = new JMenuItem("清除(D) ");je_selectAll = new JMenuItem("全选(A) ");je_find = new JMenuItem("查找(F) ");je_replace = new JMenuItem("替换(R) ");je_copy.addActionListener(this); //给弹窗式的各组件添加监听器je_paste.addActionListener(this);je_cut.addActionListener(this);je_clear.addActionListener(this);je_selectAll.addActionListener(this);je_find.addActionListener(this);je_replace.addActionListener(this);//给界面上方的菜单条添加监听器f_new = new JMenuItem("新建(N)");f_new.setAccelerator(KeyStroke.getKeyS troke('N',InputEvent.CTRL_MASK,false)); //设置带修饰符快捷键f_new.addActionListener(this);f_open = new JMenuItem("打开(O)");f_open.setAccelerator(KeyStroke.getKey Stroke('O',InputEvent.CTRL_MASK,false));f_open.addActionListener(this);f_save = new JMenuItem("保存(S)");f_save.setAccelerator(KeyStroke.getKey Stroke('S',InputEvent.CTRL_MASK,false));f_save.addActionListener(this);f_saveas = new JMenuItem("另存为");f_saveas.setAccelerator(KeyStroke.getKe yStroke(KeyEvent.VK_S,InputEvent.CTRL_ MASK|InputEvent.SHIFT_MASK));f_saveas.addActionListener(this);f_close = new JMenuItem("退出(W)");f_close.setAccelerator(KeyStroke.getKey Stroke('W',InputEvent.CTRL_MASK,false));f_close.addActionListener(this);e_copy = new JMenuItem("复制(C)");e_copy.setAccelerator(KeyStroke.getKey Stroke('C',InputEvent.CTRL_MASK,false));e_copy.addActionListener(this);e_paste = new JMenuItem("粘贴(V)");e_paste.setAccelerator(KeyStroke.getKeyStro ke('V',InputEvent.CTRL_MASK,false));e_paste.addActionListener(this);e_cut = new JMenuItem("剪切(X)"); e_cut.setAccelerator(KeyStroke.getKeyStroke ('X',InputEvent.CTRL_MASK,false));e_cut.addActionListener(this);e_clear = new JMenuItem("清除(D)");e_clear.setAccelerator(KeyStroke.getKeyStrok e('D',InputEvent.CTRL_MASK,false));e_clear.addActionListener(this);e_selectAll = new JMenuItem("全选(A)");e_selectAll.setAccelerator(KeyStroke.getKey Stroke('A',InputEvent.CTRL_MASK,false));e_selectAll.addActionListener(this);e_find = new JMenuItem("查找(F)");e_find.setAccelerator(KeyStroke.getKeyStrok e('F',InputEvent.CTRL_MASK,false));e_copy.addActionListener(this);e_replace = new JMenuItem("替换(R)");e_replace.setAccelerator(KeyStroke.getK eyStroke('R',InputEvent.CTRL_MASK,false)) ;e_replace.addActionListener(this);s_font = new JMenuItem("字体(T)");s_font.setAccelerator(KeyStroke.getKeyStrok e('T',InputEvent.CTRL_MASK,false));s_font.addActionListener(this);s_color = new JMenuItem("颜色(C)...");s_color.setAccelerator(KeyStroke.getKeyStro ke(KeyEvent.VK_C,InputEvent.CTRL_MAS K | InputEvent.SHIFT_MASK));s_color.addActionListener(this);h_editor = new JMenuItem("关于记事本");h_editor.setAccelerator(KeyStroke.getKeyStro ke(KeyEvent.VK_E,InputEvent.CTRL_MAS K));h_editor.addActionListener(this);h_help = new JMenuItem("帮助信息(H)");h_help.setAccelerator(KeyStroke.getKeyStrok e(KeyEvent.VK_I,InputEvent.CTRL_MASK) );h_help.addActionListener(this);//添加右键弹出式菜单popUpMenu.add(je_copy);popUpMenu.add(je_paste);popUpMenu.add(je_cut);popUpMenu.add(je_clear);popUpMenu.addSeparator();popUpMenu.add(je_selectAll);popUpMenu.add(je_find);popUpMenu.add(je_replace);//编辑区鼠标事件,点击右键弹出"编辑"菜单textArea.addMouseListener(new MouseAdapter(){public void mouseReleased(MouseEvent e) {if(e.getButton() == MouseEvent.BUTTON3)popUpMenu.show(e.getComponent(), e.getX(), e.getY());} //e.getComponent()和textArea具有同等效果public void mouseClicked(MouseEvent e){if(e.getButton() == MouseEvent.BUTTON1)popUpMenu.setVisible(false);}});this.setJMenuBar(jmb);this.setTitle("记事本程序");file.add(f_new); //添加文件菜单组件file.add(f_open);file.addSeparator(); //加分隔线file.add(f_save);file.add(f_saveas);file.addSeparator();file.add(f_close);edit.add(e_copy); //添加编辑菜单组件edit.add(e_paste);edit.add(e_cut);edit.add(e_clear);edit.addSeparator();edit.add(e_selectAll);edit.add(e_find);edit.add(e_replace);style.addSeparator();style.add(s_font);style.add(s_color);jmb.add(file); //添加格式菜单组件jmb.add(edit);jmb.add(style);jmb.add(help);help.add(h_editor); //添加帮助菜单组件help.add(h_help);//textArea.setWrapStyleWord(true); //设置在单词过长的时候是否要把长单词移到下一行。
java的ikm题库

java的ikm题库Java is a widely used programming language that has a vast array of libraries and frameworks, making it a popular choice for developers. However, one challenge that developers face is finding reliable and comprehensive resources to enhance their knowledge and skills in Java. This is where the IKM question bank comes into play. The IKM question bank is a collection of Java-related questions that aims to test the proficiency and understanding of developers in various aspects of the language.One perspective to consider is the usefulness of the IKM question bank for developers. The question bank covers a wide range of topics, including core Java concepts, object-oriented programming, data structures, algorithms, and design patterns. This comprehensive coverage allows developers to assess their knowledge and identify areas for improvement. By answering the questions in the question bank, developers can gain a deeper understanding of Java and enhance their problem-solving skills.Another perspective to consider is the difficulty level of the questions in the IKM question bank. The questions are designed to challenge developers and assess their proficiency in Java. Some questions may require a deep understanding of specific Java concepts, while others may test the ability to apply those concepts in real-world scenarios. This level of difficulty ensures that developers are pushed to expand their knowledge and think critically about Java programming.Furthermore, the IKM question bank provides developers with an opportunity to practice and refine their Java skills. By attempting the questions and reviewing the answers, developers can identify their strengths and weaknesses. This self-assessment allows developers to focus on areas that require improvement, thereby enhancing their overall proficiency in Java programming.However, it is important to note that the IKM question bank should not be the sole resource for learning Java. While it provides a valuable assessment tool, developersshould also explore other resources such as books, tutorials, and online courses to gain a comprehensive understanding of the language. Additionally, practical experience and hands-on projects are crucial for honing Java skills, as they provide real-world application and problem-solving opportunities.In conclusion, the IKM question bank serves as a valuable resource for developers looking to enhance their knowledge and skills in Java. It offers a comprehensive coverage of Java concepts and challenges developers tothink critically and apply their knowledge. However, it should be used in conjunction with other resources and practical experience to ensure a well-rounded understanding of the language. By utilizing the IKM question bank and other learning materials, developers can strengthen their Java proficiency and excel in their programming endeavors.。
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
目录Java语法 (2)Java的编译 (2)acm.program Hierarchy(层次) (2)acm.graphics.* (3)GCanvas and GraphicsProgram (3)GObjects (3)Common Methods (3)Interface (4)GLabel (4)Gline (4)GRect, GOval, GArc, GImage (4)GPolygon (5)GCompound (5)Event-driven Programs (6)Mouse Events (6)Keyboard Events (6)Character and String (7)Character Class (7)String (7)acm.util.* (8)Random Generator (8)java.util.* (9)StringTokenizer (9)Java语法Java的编译The Java Interpreter(编译):Source file—Compiler—Class files—Linker—JAR archive(存档) —JVM(Java Virtual Machine)—Run Other class filesacm.program Hierarchy(层次)— ConsoleProgramApplet—Japplet—Program — DialogProgram— GraphicsProgramacm.graphics.*Structure of acm.graphics Package—GCanvas, GPoint, GDimensions, GRectangle, GMath;GObject —GLabel, GRect (GRounfRect, G3DRect), GOval, GLine, GArc, GImage, GPoltgon, GCompound;Interface: GFillable, GResizable, GScalable, GContainer.GCanvas and GraphicsProgramMethods in GCanvas and GraphicsProgramvoid add(object) Adds the object to the canvas at the front of the stackvoid add(object, x, y) Moves the object to (x, y) and then adds it to the canvasvoid remove(object) Removes the object from the canvasvoid removeAll() Removes all objects from the canvasGObject getElementAt(x,y) Returns the frontmost GObject at (x, y), or nullif noneint getWidth() Returns the width in pixels of the entire canvasint getHeight() Returns the height in pixels of the entire canvasvoid setBackground(color) Sets the background color of the canvasMethods are available in GraphicsProgram onlyvoid pause(milliseconds) Pauses the program for the specified time in millisecondsvoid waitForClick() Suspends the program until the user clicks the mouseGObjectsCommon Methodsvoid setLocation(x,y) Resets the location of the object to the specified pointvoid move(dx,dy) Moves the object dx and dy pixels from its current position double getX() Returns the x coordinate of the objectdouble getY() Returns the y coordinate of the objectdouble getWidth() Returns the horizontal width of the object in pixelsdouble getHeight() Returns the vertical height of the object in pixelsboolean contains(x, y) Returns true if the object contains the specified pointvoid setColor(color) Sets the color of the objectColor getColor() Returns the color currently assigned to the objectvoid setVisible(boolean) Sets the visibility flag (false=invisible, true=visible)boolean isVisible() Returns trueif the object is visiblevoid sendToFront() Sends the object to the front of the stacking ordervoid sendToBack() Sends the object to the back of the stacking ordervoid sendForward() Sends the object forward one position in the stacking orderInterfaceGFillable(GRect, GOval, GArc, GPolygon) 填充void setFilled(boolean) Sets the fill state for the object (false=outlined, true=filled)boolean isFilled() Returns the fill state for the objectvoid setFillColor(color) Sets the color used to fill the interior of the objectColor getFillColor() Returns the fill colorGResizable(GOval, GRect, GImage) 重置大小void setSize(width, height) Sets the dimensions of the object as specifiedvoid setBounds(x, y, width, height) Sets the location and dimensions togetherGScalable(GLine, GOval, GRect, GArc, GCompound, GImage, GPolygon,) 对象放缩void scale(sf) Scales both dimensions of the object by sfvoid scale(sx, sy) Scales the object by sx horizontally and sy verticallyGLabelConstructornew GLabel(text, x, y) Creates a label containing the specified text that begins at the point (x, y).Methods specific to the GLabel classvoid object.setFont(“font”) Sets the font used to display the label as specified by the font string. Form "family-style-size" “字体-字形-大小”字形包括PLAIN(普通), BOLD(加粗), ITALIC(斜体), BOLDITALIC.void Object.setLabel(String) Set the content of the labelGlineConstructornew GLine(x0, y0, x1, y1) Creates a line extending from (x0, y0) to (x1, y1).Methods specific to the GLine classvoid object.setEndPoint(x, y) Set the end point of the lineGRect, GOval, GArc, GImageConstructornew GRect(x, y, width, height) Creates a rectangle whose upper left corner is at (x, y) of the specifiedsize.new GOval(x, y, width, height) Creates an oval that fits inside the rectangle with the same dimensions.new GArc(x, y, width, height, start angle, sweep angle) Creates an arc whose upper left corner is at (x, y) of the specified size and from start angle to the end angle by sweep angle.GFillable(GRect, GOval, GArc, GPolygon) 填充void setFilled(boolean) Sets the fill state for the object (false=outlined, true=filled) boolean isFilled() Returns the fill state for the objectvoid setFillColor(color) Sets the color used to fill the interior of the objectColor getFillColor() Returns the fill colorGResizable(GOval, GRect, GImage) 重置大小void setSize(width, height) Sets the dimensions of the object as specifiedvoid setBounds(x, y, width, height) Sets the location and dimensions togetherGScalable(GLine, GOval, GRect, GArc, GCompound, GImage, GPolygon,) 对象放缩void scale(sf) Scales both dimensions of the object by sfvoid scale(sx, sy) Scales the object by sx horizontally and sy verticallyGPolygonCreate an empty Gpolygon objectaddVertex(x, y) (x and y relative to reference point of polygon)addVertex(x, y) or addEdge(dx, dy)Polygon "closed" for youMethods specific to the GPolygon classvoid object.addVertex(x, y) adds a new vertex relative to the reference pointvoid object. addEdge(dx, dy) adds a new vertex relative to the preceding oneGCompoundGCompoundallows for combining several graphics objects so they behave like one GObject.GCompound has a reference point that all objects are added with respect to.public class * extends GCompound通常由构造函数和其他函数组成Event-driven ProgramsWhen users interact with computer, they generate events (e.g., moving/clicking the mouse, typing, etc.) Can respond to events by having listener for events (addMouseListeners() and addKeyListerners())Use Java library the deals with events: import java.awt.event.*;Methods of a listener get called asynchronously when events occur.Mouse Eventsvoid mouseClicked(e) Called when the user clicks the mousevoid mousePressed(e) Called when the mouse button is pressedvoid mouseReleased(e) Called when the mouse button is releasedvoid mouseMoved(e) Called when the user moves the mousevoid mouseDragged(e) Called when the mouse is dragged with the button down// Called on mouse press to record the coordinates of the click */public void mousePressed(MouseEvent e) {last = new GPoint(e.getPoint());gobj = getElementAt(last);}// Called on mouse drag to reposition the objectpublic void mouseDragged(MouseEvent e) {if (gobj != null) {gobj.move(e.getX() - last.getX(), e.getY() - last.getY());last = new GPoint(e.getPoint());}}Keyboard Eventsvoid keyPressed(e) Called when the user presses a keyvoid keyReleased(e) Called when the key comes back upvoid keyTyped(e) Called when the user types (presses and releases) a keyCharacter and StringCharacter ClassMethods in the Character Classstatic boolean isDigit(char ch) Determines if the specified character is a digit.static boolean isLetter(char ch) Determines if the specified character is a letter.static boolean isLetterOrDigit(char ch) Determines if the specified character is a letter or a digit.static boolean isLowerCase(char ch) Determines if the specified character is a lowercase letter.static boolean isUpperCase(char ch) Determines if the specified character is an uppercase letter.static boolean isWhitespace(char ch)Determines if the specified character is whitespace (spaces and tabs).static char toLowerCase(char ch) Converts ch to its lowercase equivalent, if any. If not, chis returned unchanged.static char toUpperCase(char ch) Converts ch to its uppercase equivalent, if any. If not, chis returned unchanged.StringMethods in the String Classint length() Returns the length of the stringchar charAt(int index)Returns the character at the specified index. Note: Strings indexed starting at 0. String substring(int p1, int p2)Returns the substring beginning at p1 and extending up to but not including p2 String substring(int p1)Returns substring beginning at p1and extending through end of string. boolean equals(String s2)Returns true if string s2is equal to the receiver string. This is case sensitive.int compareTo(String s2) Returns integer whose sign indicates how strings compare in lexicographic orderint indexOf(char ch) or int indexOf(String s) Returns index of first occurrence of the character or the string, or -1 if not foundString toLowerCase() orString toUpperCase()Returns a lowercase or uppercase version of the receiver string 注:String赋初值时可以为空,即String str = "";Random Generator/* Private instance variables */private RandomGenerator rgen = RandomGenerator.getInstance()Methods to Generate Random objectint nextInt(int low, int high) Returns a random int between low and high, inclusive.int nextInt(int n) Returns a random int between 0 and n-1double nextDouble(double low,double high)Returns a random doubled in the range low≤d< high.double nextDouble() Returns a random doubled in the range 0 ≤d< 1.boolean nextBoolean() Returns a random boolean value, which is true50 percent of the time.boolean nextBoolean(double p) Returns a random boolean,which is true with probability p, where 0 ≤p≤1.Color nextColor() Returns a random color.StringTokenizerConstructorStringTokenizer tokenizer = new StringTokenizer(line) Creating a tokenizerfor a string lineCommon methods of StringTokenizerboolean hasMoreTokens() If more token in the string, return tureString nextToken() Ruturn a token to an object string。