Java Beginner Notes Summary day2

Source: Internet
Author: User
Tags arithmetic arithmetic operators bitwise bitwise operators logical operators

Character Set : Used to encode and decode characters.
Defines a number of characters and integers corresponding to the relationship, the character set has many kinds of
Example: ASCII, Utf-8, Gbk,unicode (utf-16)
ASCII: The most basic character set, defined (numbers, letters, commonly used punctuation marks), and other character sets are extended from ASCII.

Character encoding (the process of storing character information): The process of converting "character" to "integer" of a specified character set
Character decoding (the process of displaying character information): The process of converting "integer" to "character" of a specified character set

Char: Store one character
Occupying space: 2 byte
Character Set: Unicode (UTF-16)
Integer range: 0-65535

Defining character literals
Char ch= ' single character ';
Defining characters by (0-65535) integer value
char ch= literal integer;

String: Stores 0 to more characters
Character Set: Unicode (UTF-16)

Defining string Literals
String str= "0 to more characters";
string concatenation
1) string + string: Concatenate two strings to produce a new string
2) string + other types: Convert other types to strings (the base type is the string representing the value), then connect

Note the point:
Char+char: Not a string connection, but a conversion to an int integer for an addition operation

Type conversions
Automatic type conversion
1) Small Conversion Large
2) Compiler-Optimized

Forcing type conversions
2) Large Conversion small
Syntax: small data type variable = (small data type) value of large data type;
Note the point:
Coercion of type conversions is risky, data anomalies can occur (out of bounds), and programmer control is required.

Basic API (basic functionality of the Java environment)

1) Print content to the console

2) Generate random numbers
Math.random ();//each execution gets a random value of type double of [0,1]

3) Get the contents of user console input
A) The beginning of the Java file-"Import Java.util.Scanner;
b) access to managers--"Scanner sc=new Scanner (;
c) data entered by the manager's user String Basic types: other basic types
Execution of, will be suspended program execution, waiting for user input, input completed click Enter, the program will
The user-entered content is converted to the value of the corresponding type and returned. Basic type: The input must be the corresponding type range of values, or will be error inputmismatchexception

Watch out.
1) small type and large type calculation, and then calculate the small type to large type

Arithmetic operators :
+-* = = same as Math
/(except): divide integers to get or integers, convert dividend or divisor to decimals and then calculate
% (modulus, residual): Note: The remainder is the same as the dividend symbol

Extension Operator: The re-arithmetic operator simplifies its operation on the basis of

Self-increment auto-decrement operator
Two operations were done
1) Add 1 or minus 1 for yourself
2) produces a value of its own

Order of execution
A) + + or--before the variable: first 1) after 2)
b) + + or--after the variable: first 2) after 1)

Relational operator: A relationship that must have two values satisfies the requirement, satisfies (true), does not meet (false)
= =: Determines whether two values are equal and returns true, otherwise false
! =: Determine if two values are unequal, equal returns false, otherwise true
= =: And! = is for basic type comparison content, cannot compare reference type, reference type-"Equlas

Logical operators:
Logic and &&: operation of two condition values, all satisfied then return true, otherwise false
Logical OR | | : operates two condition values, returns true if one satisfies, otherwise false
Logical NOT!: Take the opposite value

Short Circuit problem:
1) Logic and short circuit: the first value is false after the second value does not execute
2) Logical OR Short circuit:: The first value is true after the second value does not execute
Bitwise operators (Understand):
Bitwise operator does not short circuit
Identifier--"mandatory requirements
1) numbers, letters, _,$ four components
2) numbers cannot begin
3) cannot be a Java keyword
Naming specification-—— Convention
Class Name: First letter of each word, other letters lowercase
Usercontroller PersonInfo
Method name and variable name: First word all lowercase, other words first uppercase, other letters lowercase
UserName Usersex Userphone

Java Beginner Notes Summary day2

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: 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.