project |
content |
This work belongs courses |
https://www.cnblogs.com/nwnu-daizh/ |
Where this requirement in the job |
https://www.cnblogs.com/nwnu-daizh/p/11475377.html |
Job learning objectives |
|
Essay Bowen text content:
Part I: similarities and differences between Java and C combined with relatively basic grammar summarizes theoretical knowledge (30 points) this week
1, Java Application program structure;
1> Java source logical configuration divided into two parts: a program header of the packet references and the definition of the class;
2> Java source physically consists of three parts, respectively, statements, and blank blocks.
2, and variable data types Java language;
1> Java programming language defines eight basic data types, divided into four categories: integer type (byte, short, int, long), the text type (char), floating point type (double, float) and Logical ( boolean);
2> variable declaration also called to create variables. Variable declaration statement is executed, the system opens a space corresponding to the data type stored in the variable memory and given an initial value. The definition of a variable name must meet the rules of naming identifiers for variable names of a word, the first letter should be capitalized if the variable name is composed of a plurality of words, we need to use hump nomenclature.
3, Java operators construction of various types of expression;
Depending on the operator, the corresponding expressions into the following categories: arithmetic, relational expressions, logical expression, assignment expressions, these are numerical expressions.
4, Java Application technology input and output;
1> Keyboard Input:
Scanner in = new Scanner (System.in); // call the function
int cnt = in.nextInt (); // Input
2> Output
system.out.print();
5, Java process control techniques (branch, loop);
Process control is divided into three basic configurations: sequential structure, branched structure and cyclic structure.
1> branched structure
if-else statement
switch statement
2> loop
for loop
while loop
do-while statement
6, Math class, use the String class.
1> Array
int a [] = new int [length]; // create an array
for (int i: a) // for each iterate
{
}
2>字符串
Java字符串分为两类:一类实在程序中不会被改变长度的不变字符串:如String s1="hello!";
二类实在程序中会被改变长度的可变字符串:如StringBuilder s1=new StringBuilder("world");
Java环境为了存储和维护这两类字符串提供了Strin和StringBuffer两个类。
7、本周学习的内容有95%和c语言有着异曲同工之妙,它是在c语言的结构基础上加入了属于Java的独特内容;
8、Java和c语言在与语法上有着较大的差异,java是一门基于对象的语言,它的所有方法都是对象的方法;
第二部分:实验部分
实验名称:实验二 Java基本程序设计(1)
1. 实验目的:
(1)进一步熟悉命令行和IDE两种方式下java程序开发的基本步骤;
(2)掌握Eclipse集成开发环境下导入Java源程序的过程;
(3)掌握Java语言构造基本程序的数据类型、变量、运算符、各类表达式、输入输出、流程控制的基本语法;
(4)掌握Math类、String类、StringBuilder类的用法。
3. 实验步骤与内容:
实验1 程序互评(10分)
实验2 (5分)
编写包含以下代码片段的java应用程序,输出字符串类对象s3的值。
1> 代码如下
package hello;
public class s {
public static void main(String[] args)
{
String s1="Hello!";
String s2="World";
String s3=s1+s2;
System.out.println(s3);
}
}
2> 运行结果如下
实验3 (5分)
更改实验2中s1、s2、s3为StringBuilder类对象,观察程序运行结果并与实验2结果进行对比,理解String类对象与StringBuilder类对象的区别。
1> 代码如下
package hello;
public class s {
public static void main(String[] args)
{
StringBuilder s1=new StringBuilder("Hello!");
StringBuilder s2=new StringBuilder("World");
StringBuilder s3=new StringBuilder();
s3.append(s1);
s3.append(s2);
System.out.println(s3);
}
}
2> 运行结果如下
3>String类对象更像是一个数据类型;
而Stringbuilder类对象需要先创建对象, 然后调用这个对象的某个方法来实现某些操作。
实验4 (5分)
在命令行方式下调试运行下列程序,理解java应用程序命令行参数的用法。
1> 代码如下
public class Message { public static void main(String[] args) { if (args[0].equals("-h")) System.out.print("Hello"); else if(args[0].equals("-g")) System.out.print("goodbye,"); for(int i=1;i<args.length;i++) System.out.print(" "+args[i]); System.out.println("!"); } }
2>命令行运行结果如下
实验5 java程序导入(5分)
Eclipse环境下导入第3章示例程序InputTest.java步骤:
(1)新建java project如下图:
(2) 选择File->import->File ystem->Next,打开文件导入窗口如下图,点击上方Browse选择导入源程序并选中,点击下方Browse选择源程序导入位置为新项目InputTest/src位置后,点击finish完成导入。
(3) 打开InputTest项目src文件夹的缺省包,双击InputTest.java在IDE源程序编辑区打开文件。
(4) 右键单击InputTest.java文件名打开快捷菜单,选择Run as->java application运行此程序,结合程序运行结果,理解代码中Scanner类对象用法,掌握java控制台输入方法。
实验6 文件读写程序测试(10分)
按照实验5操作步骤,导入WriteReadFileTest.java示例程序,运行程序并理解程序代码,观察项目文件夹下文件myfile.txt的内容,掌握文件的输入输出操作。
实验7 (5分)
按照实验5的操作步骤,导入第3章3-3——3-4示例程序,掌握两个程序循环控制结构的用途
1> 3-3
2> 3-4
实验8 (5分)
按照实验5的操作步骤,导入第3章3-5示例程序,理解抽奖概率计算算法。
4. 实验总结:(10分)
本章学习的内容不算难点,但却是学习的重点。它是学好java的基础,本章学习的知识点基本与c语言的基础知识差不多,只有大约5%的部分有着java语言自己独特的内容。通过本章的学习,我学习了Java Application程序结构;学习了Java语言的数据类型与变量;学习了使用Java运算符构造各类表达式;学习了Java Application输入输出技术;学习了Java流程控制技术(分支、循环);学习了Math类、String类的用法。虽然掌握的不是很熟练,但“久久为功”,通过长时间的练习,我也相信自己能够更上一层楼。