




版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、Introduction to JavaThe Programming ProcessThe programming process1. Understand the problem2. Design a solution3. Run and debug.AlgorithmsWhat is an algorithm? An algorithm is an ordered plan not in a specific computer language. Is order important? You bet it is. Look at the following set of actions
2、. Wet hairRinseAdd shampooRepeatLatherWhat is being described?You are correct. Its the act of shampooing hair. Note the order; it is incorrect. If the operation was completed following these instructions as printed above, the person would be bubbly and not clean. ORDER IS IMPORTANT!Think about build
3、ing a peanut butter and jelly sandwich. Put peanut butter on one side of bread. Put jelly on another side of bread.What if we put the peanut butter on one side of a slice of bread and the jelly on the other side of the same slice? It would be messy and not very easy to eat! BE VERY SPECIFIC!The JAVA
4、 Development ProcessSource CodeWhat is source code? Its the code you type in the editor, your program.CompilerWhat is the compiler? The compiler translates the program (the users instructions) into machine language in ahead of the program run. During this action, the compiler will check for spelling
5、 and other syntax errors. Each machine has its own specific machine code.Interpreters An interpreter, like a compiler, translates the program code into machine language; however, unlike the compiler the program translates each line of code as it is executed.The Java Virtual MachineThe system where a
6、 program is translated into a general machine language called bytecode by a device called a compiler-interpreter. This general (generic) machine language allows for the portability of the program. Java bytecodes are machine-independent; it is semi-compiled code that allows your Java code to be trans
7、mitted over the Internet and executed on another computer even if that computer is of an entirely different type.Execution Here is where the logic/programming errors occur. (The program runs but the results are not correct).Editors, Compilers, and the Software Design ProcessIf there are errors, revi
8、se The EDITOR(where you type the program)Checks for Syntax ErrorsThe CompilerOKAYBytecodePCVirtual MachineMac, etcVirtual MachineHow does Java work? Other High Level LanguagesIf there are errors, revise The EDITOR(where you type the program)Checks for Syntax ErrorsThe Compiler: checks for errorsOKAY
9、BytecodePCVirtual MachineMac, etcVirtual MachineTranslator: translates source code into bytecodeJavaIf there are errors, revise The EDITOR(where you type the program)Checks for Syntax ErrorsThe CompilerOKAYByte codePCVirtual MachineMac, etcVirtual MachineNote: The translator is “missing. The Java Vi
10、rtual Machine (JVM) compiles and translates into byte code in one operation. This is done via software and not hardware. One should also be aware that the byte code generated by the JVM will run on any machine (MAC, PC, UNIX). The source code is the same for Macs, PCs, etc.What is Java?Java is a pro
11、gramming language written in byte code. A source program is a text file that contains a program (such as above) written in a programming language ://java5. An applet sends byte code from one computer to another via the Internet. The Programming ProcessThe programming process4. Unders
12、tand the problem5. Design a solution6. Run and debug.Programming in JavaA Java program is composed of classes (as few as one, as many as ). We begin with output to the monitor. The complete program below will output to the monitor the phrase: HELLO WORLD! / Print demo / program description (not code
13、)/ Ella Glazer 8 03/ your name and date public class Hello/ class declarationpublic static void main(String args ) / this is the main method System.out.println("HELLO WORLD!"); /statements (lines of code) / end main ./ end class1. Note that public, class, etc. is in lower case. Java is cas
14、e-sensitive. 2. The brackets ( ) denote the beginning and ending of a class, method, etc.3. Every Java program (not applets) has a main method. 4. Static variables and methods: when information must be shared among all instances of a class. More on Static later.5. Every Java program main method has
15、a return type. In this case, void means nothing is returned.6. The name of the method (in this example and for most of this course) is main.7. WHITE SPACE: In order to keep the programs readable we will be using a lot of white space which consists of indenting and skipping lines. Remember I am readi
16、ng and grading these programs. Note the indenting. While not required it makes reading the code easier.8. Comments: There are lines in a program that are not part of the program but are important, such as your name, description of what the program does, or assignment #, etc. / or /* */. This is call
17、ed documentation.9. Class Naming Conventions: classes are usually named with an upper case letter. Whats the name of the class used above?10. public static void main ( String args ) shows where the program will start running. The word main means that this is the main method - where the Java virtual
18、machine (The abstract computer on which all java programs are run.) will start running the byte code version of the program. 10. ; Every statement ends with a semicolon.11. System.out.println(" Hello World "); This statement writes the character(s) inside the quotation marks to the monitor
19、 of the computer system and takes the cursor to the next line while System.out.print (“something); will leave the cursor at the last item printed.How to hand in assignments. · Run it, · Copy the output and put into a Word document· Copy the code and put it into the same Word document as above.· Attach to an email to put your name and class in the subject./*print demo by E.Glazer 8-13*/Note: anything inside /* */ is a comment public class
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 《国防教育入门》课件
- 上海贝派配套各品牌变频器电阻电抗器滤波器选型样本
- 潍坊工程职业学院《药剂学综合》2023-2024学年第一学期期末试卷
- 江西省永新县达标名校2025届初三下学期第三次质量检测试题语文试题含解析
- 绍兴文理学院《中国民间音乐概论》2023-2024学年第一学期期末试卷
- 信阳职业技术学院《普通话》2023-2024学年第二学期期末试卷
- 临沂大学《建筑防火设计》2023-2024学年第一学期期末试卷
- 四川省营山县2025年初三英语试题下学期期中考试英语试题含答案
- 漯河医学高等专科学校《医疗器械生物相容性评价》2023-2024学年第二学期期末试卷
- 上海民航职业技术学院《生物医学工程研究的伦理及学术道德》2023-2024学年第二学期期末试卷
- 五年级下册数学课件 -4.1 用数对确定位置 ︳青岛版 (共20张PPT)
- 柏拉图分析案例
- 岩棉项目申报书_参考模板
- 二衬带模注浆施工方案
- 施工组织设计方案交底记录
- 《英语委婉语与忌语》PPT课件.ppt
- ISO9001-14001-2015内部审核检查表
- 风险和机遇应对措施有效性评审记录表副本
- 调查问卷设计-课件PPT
- 照金参观学习心得
- 井下电缆着火应急演练预案
评论
0/150
提交评论