201771010142 Zhang Yan Java Basic program Design structure second week study summary

Source: Internet
Author: User
Tags float double mathematical functions

Chapter Three basic program design structure of Java

The first part of theoretical knowledge learning

A basic knowledge:

1. Identifier: composed of letters. Underscores, dollar signs, and numbers, the first symbol cannot be a number, and can be used as the class name. The name of the variable. The name of the method. Array name and file name.

2. Keywords: some words in the Java language that have been given a specific meaning, the keyword cannot be used as a variable name.

3. Note: ①//②/* and/*③/** start, */End

Two data types:

integer type (int, short, long, byte) floating-point type (float, double) character type (char) floating-point type (float double) Boolean type (Boolean)
In addition, Java does not have a unsigned type, and in Java, Boolean values and integers cannot be converted to each other.
Three variablesin Java, each "variable belongs to a type." When declaring a variable, the type to which the variable belongs is before the variable name. In Java, a row can declare multiple variables. Declaring each variable individually can improve the readability of the program.
1 Variable initialization: After a variable declaration, it must be explicitly initialized with an assignment statement, and in Java, a variable declaration can be made anywhere in the code. The declaration of a variable is as close as possible to the place where the variable was first used, which is a good program writing style. You cannot declare two variables of the same name within the same scope.
2. Definition of constants: In Java, use the keyword final to indicate constants. The customary constant names are capitalized. In Java, you often want a constant to be used in multiple methods in one by one classes, often referred to as class constants. Four operators : Various operators related to object-oriented operations, including arithmetic operator increment operator and decrement operator relational operator logical operator bitwise operatorMathematical functions: Mathematical functions are included in the math class. Type conversions: Implicit type conversions enforce type conversions Five strings:A Java string is a sequence of unicodc characters that is the basic data structure of an organization's characters, similar to a character array. There is a built-in string type, but a Java-predefined class string is provided in the standard Java class library. In Java, strings are treated as objects. the string that needs to be used in the program can be divided into two categories: the immutable string class that will not be modified and changed after creation, and the build string StringBuilder class that allows for changes and changes after creation. The second part of the experimental part

1, the purpose and requirements 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) Master the Java Language constructs the basic program data type , the variable , the operator, each kind of expression, the input output, the flow control the basic grammar;

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

2. Experiment contents and Steps

Experiment 1: write the Java application and output 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)

Experiment 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;

Experiment 3: Change Experiment 2 s1,S2,S3 as StringBuilder class object, observe the program running result and experiment 2 results are compared to understand the difference between a string class object and a StringBuilder class object.

Experiment 4: Run the following program in command-line mode 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 ("!");

}

}

Check the correctness of the program in Eclipse first

To downgrade the pilot program in the command line mode

Lab 5: Import Chapter 3 sample program Inputtest.java steps in Eclipse environment :

(1) new Java project such as:

(2) select file->import->file ystem->next, open the File import window such as, click on the above Browse Select Import source program and select, click below Browse 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 of the Inputtest Project Src folder, and double-click Inputtest.java to open the file in the IDE's source program 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, mastering the Java Console input method.

Experiment 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 the file.

Experiment 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, master the use of irregular arrays.

Part III: Experimental Summary:

This experiment is more familiar with the basic steps of Java program development in two ways of command line and IDE, mastering The process of importing Java source program under Eclipse integrated development environment; mastering Java Language constructs the Basic program data type , the variable, the operator, each kind of expression, the input output, the flow control basic syntax; Master The use of the string class, the StringBuilder class, and the array class .

The experiment was more complicated than the first experiment . But with the last Test of eclipse, the understanding of the relatively smooth. The first three experiments mainly on the basic Java grammar, the common mistake is that double quotation marks should be used in the English state, as well as many different from the C language grammar knowledge, through the experiment, these errors have a more profound understanding. Experiment four on the basis of modifying the syntax error of the program, the last Learning command line method of invocation also has a more in-depth study. The next few experiments are basically to import the program in Eclipse, this is a new learning content, in the first import a little bit of a problem, the latter several times more skilled, basically no problem. Overall, the experiment was relatively rewarding and the process was not very difficult. Not only in the experimental class, but also after the lesson took a part of the time to practice.

201771010142 Zhang Yan Java Basic program Design structure 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.