版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
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. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 高中数学立体几何二级结论
- 2027届江苏省泰州市兴化市顾庄区化学九年级第一学期期末学业水平测试模拟试题含解析
- 2027届泰州市智堡实验学校九上物理期末复习检测模拟试题含解析
- 濉溪县2027届化学九年级第一学期期末教学质量检测试题含解析
- (新)实习协议(劳动合同)
- (新)机械设备维修保养合同3
- 2027届合肥市寿春中学九年级物理第一学期期末复习检测试题含解析
- 新能源动力测试题及参考答案
- 幼儿园大班多彩的秋天教案反思
- 广东省广州市广雅中学2027届化学九年级第一学期期末达标检测模拟试题含解析
- 《土木工程智能施工》课件 第10章 智能施工综合应用案例
- 企业安全风险评估检查表风险管理场景
- 园区巡检管理办法
- 2025年二中招生考试题目及答案
- 每日餐厅销售记录统计表
- 石料破碎安全协议书
- 计算机三级网络技术题库单选题100道及答案
- 草地与牧草管理学
- 湖南省长沙市一中双语实验学校2024-2025学年九年级下学期入学考试英语试卷(含笔试答案无听力原文及音频)
- 《微信小程序开发-从入门到项目实战》高职全套教学课件
- 听王荣生教授评课(重点笔记)
评论
0/150
提交评论