201874040116- Li Xin "object-oriented programming (java)" the second week of learning summary

 

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. Teachers adapt teaching methods, to complete the study this week, according to independent study theoretical knowledge requirements;
  2. Master the Java Application Program Structure;
  3. Master and variable data types Java language;
  4. Learn to use Java operator construction of various types of expression;
  5. Java Application control input and output technology;
  6. Master the Java process control technology (branch, loop); (Key)
  7. Math master class, String class usage. (difficulty)

Part I: similarities and differences between Java and C combined with relatively basic grammar, summarizes theoretical knowledge this week

  1. Three annotation method   which / * start * / annotation method is not the end of the special annotation method can automatically generate documentation c language.

  2. Data type    compared with c language: shaping machine independent operating range; integer data type adds only one byte of a byte;

             Different Boolean value (Boolean) type, c language is 0 and 1 and may be interchangeable with integer values, java is false, true not interchangeable.

  3. variables and constant   variable names of characters that can be used more than the other is basically the same C; defining constants C and different methods, using the final keyword to define constants.

  4. String     implementation string C with the use of different arrays of characters are created by string operations, and its method comprising the String Class; empty string is a string of length 0, with different null string.

  The input and output     when the input through the console, a Scanner need to construct the object, and with a "standard input stream" associated with the System.in; may be used System.out.printf () method to output data to the console.

  6. The flow control     conditional statement: if-else;

             Loop: while () {} do {} while () for () {};

             Multiple selection: switch (chooice) {case 1:; case 2 :; ...... default;};

             Break statement: break (break and have a C in both the goto function), continue (with the same C);

Part II: Experimental part

Experiment name: Experiment two basic Java programming       

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.

3. Experimental procedure and content:

Experiment 1 peer review procedure    

Experiment 2 : The following code fragment comprising write java application, the output string class object s3 value.

String s1=“Hello!”;
String s2=“World”;
String s3=s1+s2;

1-> program code

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-> Run Results

Experiment 3 : Change Experiment 2 in S . 1 , S 2 , S 3 as StringBuilder class object is observed with the experimental result of the program and 2 compare the results, be understood that S Tring class object St ringBuilder difference class object.

1 -> Code

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-> Results

S Tring class object can only be assigned once, S Tring Builder class object itself can be modified directly

 

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

1 -> Code

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-> Results

Experiment . 5 : Ec of lipse introduced into the first environment 3 Zhang example program InputTest.java

 

step:

 

(1) New J AVA Project follows:

(2) Select the File-> Import -> File ystem-> the Next , open a file to import below window, click on the top B Rowse select an import source and select, click on the bottom B Rowse select the source location for the new project import the I nputTest / the src after the location, click f inish complete the import.

(3) Open the I nputTest project S RC default package folder, double-click the I nputTest . Java in the IDE open source file compilation.

(4) Right-click the I nputTest . The Java file name to open the shortcut menu, choose R un AS-> the Application the Java run this program, run in conjunction with the results of the program, understand the code Sc Anner class object usage, grasp J AVA console input method.

Experiment 6 : following the experimental 5 steps, introducing WriteReadFileTest.java example, run the program and understand the program code , Observation file folder myfile.txt content, master file input and output operations.

1-> results are as follows

SUMMARY 2-> myfile.txt follows

Experiment 7 : following the experimental 5 steps, the introduction of 3 Cap 3- 3 - 3 - . 4 the example program, the use of two master program loop control structure.

1> and 3-3 run Import

2> Import and run 3-4

 

Experiment 8 : following the experimental 5 steps, the introduction of 3 Chapter 3- 5 sample program, lottery probability calculation algorithm appreciated.

operation result:

 

 4. Experimental summary

  The course of this experiment, I mastered the basic knowledge of java programming is required to lay the necessary foundation for future learning.

Guess you like

Origin www.cnblogs.com/whitepaint/p/11488977.html