`

Java基础恶补——Operators

    博客分类:
  • Java
 
阅读更多

[SCJP Sun Certified Programmer for Java 6 Study Guide (Exam 310-065)]  chapter4

 

一. 关系运算符
1. 关系运算符的运算结果总是布尔值(true or false)。

2. 有6个关系运算符: >, >=, <, <=, ==, and !=.  ==  和 != 也被称作 equality operators.

3. 当比较字符时,Java用Unicode值作为其数值。

4. Equality operators:

1) 有2个:== 和 !=.

2) 可应用于4种类型:numbers, characters, booleans, reference variables.

5. 当比较引用变量时,当引用指向的是同一个对象时,== 的结果为true。

 

二. instanceof运算符
1. instanceof 只能应用于引用变量,用于检查1个对象是否是1个特定的类型。

2. The instanceof operator can be used only to test objects (or null) against class types that are in the same class hierarchy.

3. For interfaces, an object passes the instanceof test if any of its superclasses implement the interface on the right side of the instanceof operator.

 

三. 数学运算符
1. 有4个数学运算符: +, -, *, /,

2. % 的运算结果是除数的余数。

3. 表达式的常规运算顺序是从左到右,除非遇到()或优先级较高的运算符。

4. *, /, % 的优先于+, -.

 

四. 字符串连接运算符
1. 如果操作数是1个String,则+表示连接字符串。

2. 如果操作数都是数字类型的,则+表示加运算。

 

五. 自增自减运算符
1. 前缀++和--在应用于表达式运算之前执行;后缀则在表达式运算之后执行。

2. In any expression, both operands are fully evaluated before the operator is applied.

3. final 变量不能++或--。

 

六. Ternary (Conditional Operator)
1. 根据表达式的布尔值返回2个值中的1个:true 返回 ? 左边的值,false则返回右边的值。

 

七. 逻辑运算符
1. The exam covers six "logical" operators: &, |, ^, !, &&, and ||.

2. 逻辑运算符可以应用于2个表达式(!除外,!只能应用于boolean值)。

3. && 和 & 返回 true 当操作数都为 true.

4. || 和 | 返回 true 当操作数中1个或全部为 true.

5. && 和 || 是短路的:&& 当左边的操作数false时,不会执行右边的;|| 当左边的操作数true时,不会执行右边的。

6. & 和 | 是非短路的,两边的操作数都会执行。

7. ^ 返回true当只有1个为true。

8. ! 返回操作数的相反值。

注:BITWISE OPERATORS ARE NOT ON THE EXAM 310-065!

 

 

 

 

分享到:
评论

相关推荐

    java编程思想教学材料——第三讲Operators

    基于java编程思想(Thinking in java, TIJ)的教学PPT,教学设计请见http://blog.csdn.net/Florianjin

    Java.SE.7.Programming.Essentials

    Using Java Operators and Conditional Logic Chapter 4. Using Java Arrays Chapter 5. Using Loops in Java Code Chapter 6. Encapsulating Data and Exposing Methods in Java Chapter 7. Using Java ...

    Operators and expressions in Java_java_expression_

    按 照 运 算 符 功 能 来 分 ,将JAVA基 本 的 运 算 符 分类。

    javat编程基础

    java编程基础,Java primitive data types and related subjects, such as variables, constants, data types, operators, and expressions. Control statements Array String

    JAVA基础之java的移位运算

    // Demonstrate the bitwise logical operators. class BitLogic { public static void main(String args[]) { String binary[] = {"0000", "0001", "0010", "0011", "0100", "0101", "0110", "0111", "1000", ...

    Java2核心技术卷I+卷2:基础知识(第8版) 代码

    Operators 46 Strings 53 Input and Output 63 Control Flow 71 Big Numbers 88 Arrays 90 Chapter 4: Objects and Classes 105 Introduction to Object-Oriented Programming 106 Using Predefined ...

    Java SE 8 Programmer I Study Guide: Exam 1Z0-808

    Title: OCA: Oracle Certified Associate Java SE 8 Programmer I Study Guide: Exam 1Z0-808 Author: Jeanne Boyarsky, Scott Selikoff Length: 432 pages Edition: 1 Language: English Publisher: Sybex ...

    Java, Java, Java, Object-Oriented Problem Solving (3rd Edition)

    5. Java Data and Operators. 6. Control Structures. 7. Strings and String Processing. 8. Arrays and Array Processing. 9. Graphical User Interfaces. 10. Graphics and Drawing. 11.Exceptions: When Things ...

    python基础教程03Operators.pdf

    v 若圆的半径为3cm,求圆的面积 n π x 32 n 3.14 * 3 * 3 v 若三名学生的身高分别为: 1.65, 1.78, 1.82,求他们的平均 身高 n n (1.65 + 1.78 + 1.82) / 3 1.65+1.78+1.82 3 算术运算符(Arithmetic Operators) ...

    Apress.Beginning.Java.8.Language.Features.

    My first encounter with the Java programming language was during a one-week Java training session in 1997. I did not get a chance to use Java in a project until 1999. I read two Java books and took a ...

    JAVA白皮书(英文版)

    2.1.2Arithmetic and Relational Operators 2.1.3Arrays 2.1.4Strings 2.1.5Multi-Level Break 2.1.6Memory Management and Garbage Collection 2.1.7The Background Garbage Collector 2.1.8...

    Java Language Features 2nd Edition

    My first encounter with the Java programming language was during a one-week Java training session in 1997. I did not get a chance to use Java in a project until 1999. I read two Java books and took a ...

    Java The Complete Reference ,11th Edition.pdf

    Data types, variables, arrays, and operators Control statements Classes, objects, and methods Method overloading and overriding Inheritance Local variable type inference Interfaces and packages ...

    Java.Crash.Course.1541019245.epub

    "Java Crash Course" contains a multitude of tips and tricks, examples and exercises you can do to grow your Java programming skills to unprecedented levels. We chose the content of this book carefully...

    Teradata SQL Functions, Operators, Expressions, and Predicates

    Teradata SQL Functions, Operators, Expressions, and Predicates

    Thinking in C: Foundations for Java &amp; C++

    Chapter 3: Operators22 MinutesStart Lecture Chapter 4: Controlling Program Flow24 MinutesStart Lecture Chapter 5: Compound Data Types35 MinutesStart Lecture Chapter 6: Programming with Functions...

    Java教程补充材料

    3 The "&" and "|" Operators 4 Bit-wise Operations 5 Statement Labels with break and continue 6 Enumerated Types 7 Packages 8 Regular Expressions 9 Formatted Strings 10 The Methods in the ...

    Java, Java, Java, Object-Oriented Problem Solving (3rd Edition 2016)

    5. Java Data and Operators. 6. Control Structures. 7. Strings and String Processing. 8. Arrays and Array Processing. 9. Graphical User Interfaces. 10. Graphics and Drawing. 11.Exceptions: When Things ...

    OCA OCP Java SE 7 Programmer I - II Study Guide(SYBEX,2014)

    * Operators * Strings and arrays * Flow control and exceptions * Assertions and Java 7 exceptions * String processing, data formatting, and resource bundles * I/O and NIO * Advanced OO and design ...

    Apress.Beginning.Java.8.Fundamentals

    My first encounter with the Java programming language was during a one-week Java training session in 1997. I did not get a chance to use Java in a project until 1999. I read two Java books and took a ...

Global site tag (gtag.js) - Google Analytics