201871020225- Mu Xingyuan "object-oriented programming (JAVA)" the second week of learning summary

text:

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

1. adapt the teacher teaching, learning can be completed this week, according to independent study theoretical knowledge requirements;

2. Master Java Application Program Structure;

2. Master and variable data types Java language;

4. Java operators learn to use various types of expressions configuration;

The input and output control Java Application Technology;

6. grasp the Java process control technology (branch, loop); (Key)

7. grasp Math class, String class usage. (difficulty)

Essay Bowen text:

The first part: combination of similarities and differences between Java and C basic grammar of comparison, this week, summarizes theoretical knowledge

First, the identifier

JAVA identifier made up of letters, numbers, underscores, dollar sign components.

C language identified by letters, numbers, underscores.

Second, comments

The same way Notes Java and C Language

Third, the data type

C language and common data types in java has the following parts

1.  Integer

2.  floating point type

3. Char type

In Java, C with different types Boolean (Boolean) type, two Boolean values, respectively, are True and False, which is used to determine the logical condition. And byte type

Fourth, variable

1.  Variable names are case-sensitive.

2.  once more variables can be declared and initialized.

V. Constant

1.  In java using the keyword final indicator variables

2. The  keyword final indicates that the variable can only be assigned once, once assigned, can not be changed.

Six, operator

1.  In the C language and common java operators are arithmetic operators, and operator increment decrement operators, relational operators, Logical and Bitwise operators.

2.  In the two special operator in Java

(1) new operator to create an object

(2) Instanceof particular class return boolean operators.

3.  Priority

Seven types of conversion:

Implicit type conversions:

( 1) If the two operands is a double type, the other will be converted into double type;

( 2) if the two operands is a float type, then the other will be converted into float type;

( 3) If either operand has type long one, the other will be converted into a long type;

( 4) two numbers will be converted into int.

Eight Input Output

1. Input input through the console, a Scanner need to construct the object, and associated with the "standard input stream" System.in. Scanner in = new Scanner (System.in);

2. Use of System.out.print output (x) outputs the value of x to the console.

3. file input and output
   in order to file for reading, you need to construct a Scanner objects with a File object. For example: Scanner in = new Scanner (new File ( "myfile.txt"));
   To write to a file, you need to construct a PrintWriter object in the constructor, simply provide the file name: PrintWriter out = new PrintWriter ( " myfile.txt ");
   the PrintWriter the PrintWriter new new OUT = (" myfile.txt ");

Nine control flow

Java There are five statements:

1)  method call statement     System.out.println ( "Hello!");   

2)  expression statement   

3)  compound statement   

4)  Control statements 

5) packege statement and import statements

 

Part II: Experimental part

Experiment name: Experiment two basic Java programming (1)

1. Purpose:

( 1) become more familiar with the basic steps of the java program development and IDE command line in two ways;

( 2) master the process of importing Java source code under the Eclipse integrated development environment;

( 3) Data structure of the Java language type master basic programs, variables, operators, various types of expression, the input and output, the basic syntax of flow control;

( 4) master the use of the Math class, String class, StringBuilder class.

2. Experimental procedure and content:

Experiment 1 peer review procedure

In this peer review process, we conducted a multiplication table output peer assessment of the program, through peer assessment program, found himself for the mastery of the program there is a big problem, as well as the basic framework for the program is not enough to understand some of the basic statements place, needs to be more than usually understood.

Experimental java application 2 contains the following code fragment written in the value of the output s3 of the string class object.

String s1=“Hello!”;

String s2=“World”;

String s3=s1+s2;

(1) program code

 

package work;

 

public class first {

 

 public static void main (String [] args) {/ * framework * /
  // Generated Method Stub the TODO Auto-
  String S1 = "Hello!"; / * defines a character variable s1, and assigned to "Hello!" * /
  String s2 = "World"; / * defines a character variable s2, and assigned to "World" * /
  String S3 = s1 + s2; / * defines a character variable s3, s2 and s1 and assigned * sum /
  System.out.println (s3); / * output value s3 * /
 }

 

}

 

( 2) Run results

 

 

 

Experiment 3 Change Experiment 2 S1 , S2 , S3 as StringBuilder class object is observed with the experimental result of the program and comparing the results 2, understood String class object StringBuilder difference class object.

 (1) Code

package work;
public class second {
 public static void main (String [] args) {/ * framework * /
  // the TODO Auto-Generated Method Stub
  StringBuilder StringBuilder new new S1 = ( "the Hello!"); / * use StringBuilder establish variable variable s1, and assigned to "! the Hello" * /
  StringBuilder StringBuilder new new S2 = ( "World"); / * use StringBuilder establish variable variable s2, and assigned to "World" * /
  StringBuilder StringBuilder new new S3 = () the append (S1) .append (. S2); / * string concatenation implemented using StringBuilder * /
  System.out.println (s3); / * output value of s3 * /
 }
} (2) Results

 

 

Experiment 4 commissioning program in the following command line, understanding java application usage command-line arguments.

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(“!”);

  }

}

 

 

Experiment 5 java program introduced

Eclipse introduction of ambient Chapter 3 InputTest.java sample program steps:

(1)  New java project below:

 

 

 

(2)  Select File-> Import-> File sysem-> the Next , open the File Import window below, click on the top Browse to select the import source, select it, click on the bottom Browse to select the import source location for the new project InputTest / src rear position, click finish to complete the import.

 

 

 

(3) 打开InputTest项目src文件夹的缺省包,双击InputTest.javaIDE源程序编辑区打开文件。

(4) 右键单击InputTest.java文件名打开快捷菜单,选择Run as->java application运行此程序,结合程序运行结果,理解代码中Scanner类对象用法,掌握java控制台输入方法。

 

 

 

实验6 按照实验5操作步骤,导入WriteReadFileTest.java示例程序,运行程序并理解程序代码,观察项目文件夹下文件myfile.txt的内容,掌握文件的输入输出操作。

 

 

 

实验7 按照实验5的操作步骤,导入第3章3-3——3-4示例程序,掌握两个程序循环控制结构的用途。

 

 

 

 

 

实验8 按照实验5的操作步骤,导入第3章3-5示例程序,理解抽奖概率计算算法。

 

 

 

三. 实验总结:

在本周的学习中,我们主要学习了第三章的内容,在第三章中,我们了解了关于JAVA语言的一些基本知识,JAVA语言与C语言相比,其语法结构基本相同,但仍有部分情况有所差异,通过第三的学习我了解到了JAVA的变量,常量,关键词,标志符,数组等知识,这些都是构成java语言的基本知识,需要多看书进行了解,除此之外,对于一些基础程序进行编译,发现自己在程序编译中仍有许多不足,需要多进行编译来提高自己的动手能力,以上就是对于本周的实验总结

 

Guess you like

Origin www.cnblogs.com/muxingyuan/p/11494334.html