Zhao 201771010137 "Object-oriented Programming (Java)" Second week study summary

Source: Internet
Author: User

The first part of theoretical knowledge summary

Chapter Three Basic program design structure of Java

1. Data type: There are eight basic types,4 in shaping,2 floating-point types,1 character types used to represent Unicode-encoded character cells, char, and 1 Boolean types used to represent truth values .

2. Variable: The variable name must be a sequence that begins with a letter and consists of an initial letter or number. However, you cannot use java reserved words as variable names. After declaring a variable, the variable must be displayed initialized with an assignment statement, not an uninitialized variable '

3. Operator: arithmetic operator, increment operator and decrement operator, relational operator, logical operator, bitwise operator,new (Create object),instanceof (returns a Boolean value to indicate whether an object is a specific class or an instance of its subclass). The precedence between operators is not the same.

4. String: Conceptually, aJava string is a sequence of Unicode characters. There are two types of immutable strings, string strings , string joins, getting the length of a string, detecting whether a string is equal, converting a string to a value, and so on, and the StringBuilder class that can be changed .

5. Input and output: Read input (first constructs a scanner object, and system.out.print (x) to output the value x to the console to x the maximum non-0 digital digits allowed by the corresponding data type x. You can use s to format any object), file input and output (want to read the file, you need a file object to construct a Scanner object, the constructed scanner can have string parameters, but this scanner interprets the string as data rather than a file name; To write a file, you need to construct a printwriter object).

The second part of the experiment

1. Purpose of the experiment

(1) Further familiar with the basic steps of Java Program Development in command line and IDE two ways;

(2) Mastering the process of importing Java source program under Eclipse integrated development environment;

(3) Mastering the basic Grammar of the basic program of Java language construction, such as data type, variables, operators, various expressions, input and output, and process control;

(4) Mastering the use of the string class, the StringBuilder class, and the array class.

2. Experimental steps

(1): Write a Java application that outputs the values of the following 4 expressions.

int i=1;

Double d=1.0;

(1) 45+45*50%i--

(2) 1.5*3+d++

(3) (true) && (3>4)

(4) (i>0) | | (i<0)

(2): Write a Java application that contains the following code fragment, outputting the value of the String class object S3.

String s1= "hello!";

String s2= "World";

String s3=s1+s2;

(3): change in Experiment 2 S1, S2, S3 for the StringBuilder class object, observe the program running results and compare with experiment 2 results, understand the difference between the string class object and the StringBuilder class object.

(4): in the command-line mode, run the following program to understand the use of Java Application command-line parameters.

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

}

}

(5): In the Eclipse Environment, import the 3rd chapter of the sample program Inputtest.java steps:

1> New Java Project as

2> Select File->import->file ystem->next, open the File import window such as, click on the above browse to select the Import source program and select, click Browse below to select the source program import location for the new project inputtest/ SRC location, click Finish to complete the import.

3> Open the default package for the Inputtest Project Src folder, double-click Inputtest.java to open the file in the IDE's source editing area.

4> Right-click the Inputtest.java file name to open the shortcut menu, choose Run As->java application running the program, in conjunction with the program run results, understand the code scanner class object usage, master the Java console input method.

(6): Follow the procedure of Experiment 5, Import Writereadfiletest.java sample program, understand program code with program running result, observe the contents of file MyFile.txt under project folder, master the input and output operation of file.

(7): Follow the procedure of Experiment 5, import the 3rd Chapter sample program, each sample program summarizes the learning content from the syntax and algorithm two angles.

1> Test Retirement.java,retirement2.java,lotteryodds.java Master the loop control structure;

2> Test Bigintegertest.java, master the use of large numerical classes;

3> Test Lotterydrawing.java, master the use of arrays;

4> Test Compoundinterest.java, master the use of multidimensional arrays;

5> Test Lotteryarray.java, mastering the use of irregular arrays.

3. Experimental results

(1).

(2).

(3).

(4).

(5).

(6).

(7).

The third part of the experimental summary

through the study of this chapter, I learned the basic knowledge of identifiers, keywords and annotations, and learned about data types, variables, operators, type conversions, strings, input and output, control flow, large values, arrays and so on. And some of the basics of Java are very similar to the C language, and only part of it is different. In the course of the experiment also appeared some problems, but in the classmate and seniors help also completed the experiment, solve the problem. In the Java learning process, only by constantly writing Java programs to better understand the theoretical knowledge learned, to learn Java this course!

Zhao 201771010137 "Object-oriented Programming (Java)" Second week study summary

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.