Презентация Data Types and Operators (Java, Lecture 04) онлайн
На нашем сайте вы можете скачать и просмотреть онлайн доклад-презентацию на тему Data Types and Operators (Java, Lecture 04) абсолютно бесплатно. Урок-презентация на эту тему содержит всего 38 слайдов. Все материалы созданы в программе PowerPoint и имеют формат ppt или же pptx. Материалы и темы для презентаций взяты из открытых источников и загружены их авторами, за качество и достоверность информации в них администрация сайта не отвечает, все права принадлежат их создателям. Если вы нашли то, что искали, отблагодарите авторов - поделитесь ссылкой в социальных сетях, а наш сайт добавьте в закладки.
Презентации » Устройства и комплектующие » Data Types and Operators (Java, Lecture 04)
Оцените!
Оцените презентацию от 1 до 5 баллов!
- Тип файла:ppt / pptx (powerpoint)
- Всего слайдов:38 слайдов
- Для класса:1,2,3,4,5,6,7,8,9,10,11
- Размер файла:1.16 MB
- Просмотров:68
- Скачиваний:0
- Автор:неизвестен
Слайды и текст к этой презентации:
№5 слайд
![Simple Data Types, their](/documents_6/910648c9b43ba4b56287872f627d91fd/img4.jpg)
Содержание слайда: Simple Data Types, their Values and Operators
Simple Data Types in Java
In difference to some other programming languages, all simple data types in Java have an agreed fixed size in memory
For every simple data type a default value is defined, which is of importance with the initialisation of object and class variables (note: local variables are not automatically initialised with the default value)
№6 слайд
![Simple Data Types, their](/documents_6/910648c9b43ba4b56287872f627d91fd/img5.jpg)
Содержание слайда: Simple Data Types, their Values and Operators
Operators
Are special symbols that are used to link operands to determine a new value
According to their number of operands we can distinguish three types of operators
Single digit (monadic oder unary) operators
example: the negative sign -
Two digit (dyadic oder binary) operators
example: the addition sign +
Three digit (triadic oder ternary) operatores
example: conditional operator ? :
№7 слайд
![Simple Data Types, their](/documents_6/910648c9b43ba4b56287872f627d91fd/img6.jpg)
Содержание слайда: Simple Data Types, their Values and Operators
Logic Values (boolean)
Unary Operator (Operator Operand)
Operator Description
! logische Negation
Binary Operator (Operand1 Operator Operand2)
Operator Description Example
== Equality false == true results in false
!= Inequality false != true results in true
& logic AND
| logic OR
^ logic XOR
№9 слайд
![Simple Data Types, their](/documents_6/910648c9b43ba4b56287872f627d91fd/img8.jpg)
Содержание слайда: Simple Data Types, their Values and Operators
Truth Table (boolean)
Boolean Expressions with & and | evaluate both terms completely
In practise complete evaluation is often not required
& - operation: is one expression false, then the overall result is false
| - operation: is one expression true, then the overall result is true
The operators && and || ensure a shortened evaluation
Example
int m = 3;
int n = 5;
boolean b = (m < 5) || (n > 3);
The shortened evaluation is important to reduce the computation time for example with large arrays
№11 слайд
![Simple Data Types, their](/documents_6/910648c9b43ba4b56287872f627d91fd/img10.jpg)
Содержание слайда: Simple Data Types, their Values and Operators
Binary Operators (char, byte, short, int, long)
Operator Description Example
+ Addition 5 + 6 yields 11
- Subtraction 9 - 3 yields 6
* Multiplication 10 * 15 yields 150
/ Whole Number Division 13 / 3 yields 4
% Modulo (remainder of 20 % 7 yields 6
a whole number division)
< smaller 3 < 5 yields true
<= smaller equal 3 <= 3 yields true
> bigger 2 > 10 yields false
>= bigger equal 5 >= 6 yields false
== equal 3 == 3 yields true
!= not equal 5 != 5 yields false
№13 слайд
![Simple Data Types, their](/documents_6/910648c9b43ba4b56287872f627d91fd/img12.jpg)
Содержание слайда: Simple Data Types, their Values and Operators
Unary Operators (char, byte, short, int, long)
Operator Description Example
- Unary Negation -i
++ Increment ++i is the same as i = i+1
-- Decrement --i is the same as i = i-1
Note the difference: Pre-increment vs. Post-increment
a = ++b; // is the same as:
// b = b+1; a = b;
a = b++; // is the same as:
// a = b; b = b+1;
№14 слайд
![Simple Data Types, their](/documents_6/910648c9b43ba4b56287872f627d91fd/img13.jpg)
Содержание слайда: Simple Data Types, their Values and Operators
Bitwise - Operators (char, byte, short, int, long)
Access to binary representation of whole number data types
Numbers are viewed as a set of consecutive bits, which may be manipulated
Unary Operator (Operator Operand)
Operator Description
~ Complement (bitwise negation)
Binary Operators (Operand1 Operator Operand2)
Operator Description
& bitwise AND
| bitwise OR
^ bitwise XOR
The operators >>, >>> and << are used to shift the bits to the right or the left
№15 слайд
![Simple Data Types, their](/documents_6/910648c9b43ba4b56287872f627d91fd/img14.jpg)
Содержание слайда: Simple Data Types, their Values and Operators
Bitwise - Operators (char, byte, short, int, long)
Example for shift operator
Left-Shift-Operator <<
int a;
a = 10; 00000000 00000000 00000000 00001010
a << 3; 00000000 00000000 00000000 01010000
int a;
a = -10; 11111111 11111111 11111111 11110110
a << 3; 11111111 11111111 11111111 10110000
Equivalent to: whole-number multiplication with 23
№16 слайд
![Simple Data Types, their](/documents_6/910648c9b43ba4b56287872f627d91fd/img15.jpg)
Содержание слайда: Simple Data Types, their Values and Operators
Floating-Point-Numbers (float, double)
Unary Operators (analog to whole-number types)
- ++ --
Binary Operators (analog to whole-number types)
+ - * / % (arithmetic operators)
< <= > >= == != (comparison operators)
Note:
whole-number division: 45 / 20 Result: 2
floating-point division: 45.0 / 20.0 Result: 2.25
№20 слайд
![Expressions Expressions](/documents_6/910648c9b43ba4b56287872f627d91fd/img19.jpg)
Содержание слайда: Expressions
Expressions: Definition and Features
Expression: Processing specification, that delivers a value after execution
In the simplest case a variable or a constant
Through combination of operands, operations and round brackets we get complex expressions
Examples
radius = 5.5;
area = PI * radius * radius;
counter = counter + 1;
№21 слайд
![Expressions Brackets The](/documents_6/910648c9b43ba4b56287872f627d91fd/img20.jpg)
Содержание слайда: Expressions
Brackets
The evaluation of expressions in brackets always takes place first
Just like the rules in mathematics
Expressions may be arbitrarily nested
Notation of the nested structure is done with round brackets
All expressions are provided in linear notation
Expression are provided in line format
№23 слайд
![Expressions Operator Priority](/documents_6/910648c9b43ba4b56287872f627d91fd/img22.jpg)
Содержание слайда: Expressions
Operator Priority Rules
Well-known from mathematics:
„Point before Line“
example 6 + 7 * 3 equals 27 and not 39
In Java:
Linking of operators is governed by priorities:
An operator with high priority links stronger than an operator with a lower priority
If the priority is the same than then the associativity of the operators is evaluated
op is is left associative: X op Y op Z equals (X op Y) op Z
op ist right associative: X op Y op Z equals X op (Y op Z)
Obviously, brackets do control the evaluation order
example (6 + 7) * 3 ist 39
№27 слайд
![Expressions Mathematical](/documents_6/910648c9b43ba4b56287872f627d91fd/img26.jpg)
Содержание слайда: Expressions
Mathematical Constants and Functions
The class Math provides important mathematical constants and functions (see online documentation)
Constants
public static final double E (basis e of nat. logarithm)
public static final double PI ()
Usage: Math.E and Math.PI
Methods (Selection)
public static double abs(double x) |x|
public static double cos(double x) cos(x)
public static double sin(double x) sin(x)
public static double tan(double x) tan(x)
public static double sqrt(double x) √x
public static double exp(double x) ex
public static double pow(double x, double y) xy
Usage: for example result = Math.pow(a,b);
№28 слайд
![Definition of Constants](/documents_6/910648c9b43ba4b56287872f627d91fd/img27.jpg)
Содержание слайда: Definition of Constants
Constants in Java
Constants are defined and initialised like variables with the keyword „final“
their names are typically written in capital letters
they can not be changed
Example:
Statement and definition of constants:
Statement rewritten with constants:
red = Math.min(red + ADDED_RED, MAX_RED)
№32 слайд
![Type Conversion Type](/documents_6/910648c9b43ba4b56287872f627d91fd/img31.jpg)
Содержание слайда: Type Conversion
Type extension and selection of operators in expressions
Each expression is evaluated step by step according to the priorities and associativity of its operators
The operators choosen are the operators that fit to the type of the operands
(example: whole number division OR division for floating point numbers)
Are the types of operands different, than the „smaller“ operand will receive an automatic type conversion
Are both operands of an operation, expressions themselves, then the left operand is calculated before the right operand
№34 слайд
![Type Conversion Explicit Type](/documents_6/910648c9b43ba4b56287872f627d91fd/img33.jpg)
Содержание слайда: Type Conversion
Explicit Type Conversion: Type Casting
Explicit type conversion happens when the desired type is explicitly requested
Example
int a;
float b = 10.25f;
a = (int) b;
float-value 10.25f is converted in the int-value 10
a = (int)(b / 3.3f + 5.73f);
Note: Type casting takes place AFTER the calculation of the entire term
b / 3.3f + 5.73f
Скачать все slide презентации Data Types and Operators (Java, Lecture 04) одним архивом:
Похожие презентации
-
OOP with C. Introduction C. Data Types. Variables, expressions, statements. C decision and iteration constructs
-
Analysis and Design of Data Systems. Complex SQL Queries (Lecture 13)
-
Analysis and Design of Data Systems. Functional Dependencies and Normalization Theory (Lecture 15)
-
Analysis and Design of Data Systems. Relational Algebra 2 (Lecture 18)
-
7. Java databases and JDBC 3. JDBC Additional Tasks
-
7. Java databases and JDBC 2. JDBC Database Access JDBC
-
8. Java Databases and JDBC 1. Introduction to Databases
-
CSE 326: Data Structures. Mergeable Heaps. Lecture 22
-
Mathematical functions, characters, and strings. Introduction to Java Programming
-
Основы JDBC (Java DataBase Connectivity)