SlideShare a Scribd company logo
IMPLEMENTING ASSIGNMENT
STATEMENTS AND EXPRESSION
Chapter 3.2:
Assignment Statement
 An assignment statement changes the value
of a variable
 The assignment operator is the = sign
 Syntax for assignment statement:
variable = expression;
• E.g:
• The value that was in total is overwritten
• You can only assign a value to a variable that
is consistent with the variable's declared type
• See Geometry.java
total = 55;
Assignment Statement
//********************************************************************
// Geometry.java Author: Lewis/Loftus
//
// Demonstrates the use of an assignment statement to change the
// value stored in a variable.
//********************************************************************
public class Geometry
{
//-----------------------------------------------------------------
// Prints the number of sides of several geometric shapes.
//-----------------------------------------------------------------
public static void main (String[] args)
{
int sides = 7; // declaration with initialization
System.out.println ("A heptagon has " + sides + " sides.");
sides = 10; // assignment statement
System.out.println ("A decagon has " + sides + " sides.");
sides = 12;
System.out.println ("A dodecagon has " + sides + " sides.");
}
}
Assignment Statement
//********************************************************************
// Geometry.java Author: Lewis/Loftus
//
// Demonstrates the use of an assignment statement to change the
// value stored in a variable.
//********************************************************************
public class Geometry
{
//-----------------------------------------------------------------
// Prints the number of sides of several geometric shapes.
//-----------------------------------------------------------------
public static void main (String[] args)
{
int sides = 7; // declaration with initialization
System.out.println ("A heptagon has " + sides + " sides.");
sides = 10; // assignment statement
System.out.println ("A decagon has " + sides + " sides.");
sides = 12;
System.out.println ("A dodecagon has " + sides + " sides.");
}
}
Output
A heptagon has 7 sides.
A decagon has 10 sides.
a dodecagon has 12 sides.
Declaring, Initializing and
Assignment
j=k=x=2; equivalent to: x=2;
k=x;
j=k;
 Declare and initialize. E.g:
int x = 1;
int i =1, j=2;
Uninitialized Variables
 Error:
An Uninitialized Object
Variable
int luckyNumber;
System.out.println(luckyNumber);
// ERROR - uninitialized variable
Constants
 A constant is an identifier that is similar to a
variable except that it holds the same value during
its entire existence
 As the name implies, it is constant, not variable
 The compiler will issue an error if you try to
change the value of a constant
Constants
 Permanent data that never change during
program execution
 Example:  = 3.14159
 Declared by using the reserved word final.
 Initialized when it is declared.
 Syntax:
final datatype CONSTANTNAME = value
 Example :
final double CENTIMETERS_PER_INCH = 2.54;
final int NO_OF_STUDENTS = 20;
final char BLANK = ' ';
final double PAY_RATE = 15.75;
Data Types
 A set of values together with a set of operations.
Primitive Data Types
• The primitive data type are the fundamental data
types in Java.
Primitive Data Types
• Integral data types (deals with integers, or numbers
without a decimal part):
Primitive Data Types
 Floating-point data types (deals with
decimal numbers):
 float
 double
 boolean (deals with logical values):
 True
 False
Values and Memory Allocation for
Integral and Floating-point Data
Types
Characters
 A char variable stores a single character
 Character literals are delimited by single
quotes:
'a' 'X' '7' '$' ',' 'n'
 Example declarations:
char topGrade = 'A';
char terminator = ';', separator = ' ';
 Note the difference between a primitive
character variable, which holds only one
character, and a String object, which can
hold multiple characters
Characters
 A character set is an ordered list of characters,
with each character corresponding to a unique
number
 A char variable in Java can store any character
from the Unicode character set
 The Unicode character set uses sixteen bits per
character, allowing for 65,536 unique characters
 It is an international character set, containing
symbols and characters from many world
languages
Characters
 The ASCII character set is older and smaller than
Unicode, but is still quite popular
 The ASCII characters are a subset of the Unicode
character set, including:
uppercase letters
lowercase letters
punctuation
digits
special symbols
control characters
A, B, C, …
a, b, c, …
period, semi-colon, …
0, 1, 2, …
&, |, , …
carriage return, tab, ...
Boolean
 A boolean value represents a true or false
condition
 The reserved words true and false are the
only valid values for a boolean type
boolean done = false;
 A boolean variable can also be used to represent
any two states, such as a light bulb being on or off

More Related Content

What's hot

Effective PHP. Part 3
Effective PHP. Part 3Effective PHP. Part 3
Effective PHP. Part 3
Vasily Kartashov
 
Regular expressions in Perl
Regular expressions in PerlRegular expressions in Perl
Regular expressions in Perl
Girish Manwani
 
Effective PHP. Part 5
Effective PHP. Part 5Effective PHP. Part 5
Effective PHP. Part 5
Vasily Kartashov
 
Javascript variables and datatypes
Javascript variables and datatypesJavascript variables and datatypes
Javascript variables and datatypes
Varun C M
 
Fundamental programming structures in java
Fundamental programming structures in javaFundamental programming structures in java
Fundamental programming structures in java
Shashwat Shriparv
 
JavaScript Tutorial
JavaScript  TutorialJavaScript  Tutorial
JavaScript Tutorial
Bui Kiet
 
Perl names values and variables
Perl names values and variablesPerl names values and variables
Perl names values and variables
sana mateen
 
Unit 2.5
Unit 2.5Unit 2.5
Effective PHP. Part 2
Effective PHP. Part 2Effective PHP. Part 2
Effective PHP. Part 2
Vasily Kartashov
 
Comma operator
Comma operatorComma operator
Comma operator
Ajay Chimmani
 
PHP Unit 3 functions_in_php_2
PHP Unit 3 functions_in_php_2PHP Unit 3 functions_in_php_2
PHP Unit 3 functions_in_php_2
Kumar
 
Java Script Introduction
Java Script IntroductionJava Script Introduction
Java Script Introduction
jason hu 金良胡
 
JavaScript 101 - Class 1
JavaScript 101 - Class 1JavaScript 101 - Class 1
JavaScript 101 - Class 1
Robert Pearce
 
JavaScript: The Good Parts Or: How A C# Developer Learned To Stop Worrying An...
JavaScript: The Good Parts Or: How A C# Developer Learned To Stop Worrying An...JavaScript: The Good Parts Or: How A C# Developer Learned To Stop Worrying An...
JavaScript: The Good Parts Or: How A C# Developer Learned To Stop Worrying An...
Doug Jones
 
5 Statements and Control Structures
5 Statements and Control Structures5 Statements and Control Structures
5 Statements and Control Structures
Deepak Hagadur Bheemaraju
 
Getting started with c++
Getting started with c++Getting started with c++
Getting started with c++
K Durga Prasad
 
Javascript sivasoft
Javascript sivasoftJavascript sivasoft
Javascript sivasoft
ch samaram
 
Compiler: Programming Language= Assignments and statements
Compiler: Programming Language= Assignments and statementsCompiler: Programming Language= Assignments and statements
Compiler: Programming Language= Assignments and statements
Geo Marian
 
Lecture 23
Lecture 23Lecture 23
Lecture 23
rhshriva
 

What's hot (19)

Effective PHP. Part 3
Effective PHP. Part 3Effective PHP. Part 3
Effective PHP. Part 3
 
Regular expressions in Perl
Regular expressions in PerlRegular expressions in Perl
Regular expressions in Perl
 
Effective PHP. Part 5
Effective PHP. Part 5Effective PHP. Part 5
Effective PHP. Part 5
 
Javascript variables and datatypes
Javascript variables and datatypesJavascript variables and datatypes
Javascript variables and datatypes
 
Fundamental programming structures in java
Fundamental programming structures in javaFundamental programming structures in java
Fundamental programming structures in java
 
JavaScript Tutorial
JavaScript  TutorialJavaScript  Tutorial
JavaScript Tutorial
 
Perl names values and variables
Perl names values and variablesPerl names values and variables
Perl names values and variables
 
Unit 2.5
Unit 2.5Unit 2.5
Unit 2.5
 
Effective PHP. Part 2
Effective PHP. Part 2Effective PHP. Part 2
Effective PHP. Part 2
 
Comma operator
Comma operatorComma operator
Comma operator
 
PHP Unit 3 functions_in_php_2
PHP Unit 3 functions_in_php_2PHP Unit 3 functions_in_php_2
PHP Unit 3 functions_in_php_2
 
Java Script Introduction
Java Script IntroductionJava Script Introduction
Java Script Introduction
 
JavaScript 101 - Class 1
JavaScript 101 - Class 1JavaScript 101 - Class 1
JavaScript 101 - Class 1
 
JavaScript: The Good Parts Or: How A C# Developer Learned To Stop Worrying An...
JavaScript: The Good Parts Or: How A C# Developer Learned To Stop Worrying An...JavaScript: The Good Parts Or: How A C# Developer Learned To Stop Worrying An...
JavaScript: The Good Parts Or: How A C# Developer Learned To Stop Worrying An...
 
5 Statements and Control Structures
5 Statements and Control Structures5 Statements and Control Structures
5 Statements and Control Structures
 
Getting started with c++
Getting started with c++Getting started with c++
Getting started with c++
 
Javascript sivasoft
Javascript sivasoftJavascript sivasoft
Javascript sivasoft
 
Compiler: Programming Language= Assignments and statements
Compiler: Programming Language= Assignments and statementsCompiler: Programming Language= Assignments and statements
Compiler: Programming Language= Assignments and statements
 
Lecture 23
Lecture 23Lecture 23
Lecture 23
 

Viewers also liked

Cyberbullying film 260
Cyberbullying film 260Cyberbullying film 260
Cyberbullying film 260
teaganmclaren
 
Chapter 6.3
Chapter 6.3Chapter 6.3
Chapter 6.3
sotlsoc
 
Chapter 4.0
Chapter 4.0Chapter 4.0
Chapter 4.0
sotlsoc
 
Final flipbook presentation
Final flipbook presentationFinal flipbook presentation
Final flipbook presentation
Taryn Pilon
 
Chapter 9.3
Chapter 9.3Chapter 9.3
Chapter 9.3
sotlsoc
 
Chapter 10.2
Chapter 10.2Chapter 10.2
Chapter 10.2
sotlsoc
 
Chapter 6.6
Chapter 6.6Chapter 6.6
Chapter 6.6
sotlsoc
 
Chapter 4.3
Chapter 4.3Chapter 4.3
Chapter 4.3
sotlsoc
 
Chapter 8.1
Chapter 8.1Chapter 8.1
Chapter 8.1
sotlsoc
 
Chapter 7.2
Chapter 7.2Chapter 7.2
Chapter 7.2
sotlsoc
 
정몽준 서울시장 새누리당 후보 정책 공약 _ 33한서울88한경제
정몽준 서울시장 새누리당 후보 정책 공약 _ 33한서울88한경제 정몽준 서울시장 새누리당 후보 정책 공약 _ 33한서울88한경제
정몽준 서울시장 새누리당 후보 정책 공약 _ 33한서울88한경제 MJeNews
 
Chapter 11.1
Chapter 11.1Chapter 11.1
Chapter 11.1
sotlsoc
 
Chapter 11.3
Chapter 11.3Chapter 11.3
Chapter 11.3
sotlsoc
 
Cyberbullying by alex pitcher
Cyberbullying by alex pitcherCyberbullying by alex pitcher
Cyberbullying by alex pitcher
Phillip Pitcher
 
Presentacion leydi perezI
Presentacion leydi perezIPresentacion leydi perezI
Presentacion leydi perezI
leydip2009
 
Dangers to social media
Dangers to social mediaDangers to social media
Dangers to social media
Ryan Ward
 
Smart phone. addiction. blindness
Smart phone. addiction. blindnessSmart phone. addiction. blindness
Smart phone. addiction. blindness
SunnyBabyBabe
 

Viewers also liked (18)

Cyberbullying film 260
Cyberbullying film 260Cyberbullying film 260
Cyberbullying film 260
 
Chapter 6.3
Chapter 6.3Chapter 6.3
Chapter 6.3
 
Chapter 4.0
Chapter 4.0Chapter 4.0
Chapter 4.0
 
Final flipbook presentation
Final flipbook presentationFinal flipbook presentation
Final flipbook presentation
 
Chapter 9.3
Chapter 9.3Chapter 9.3
Chapter 9.3
 
Chapter 10.2
Chapter 10.2Chapter 10.2
Chapter 10.2
 
e-Sports
e-Sportse-Sports
e-Sports
 
Chapter 6.6
Chapter 6.6Chapter 6.6
Chapter 6.6
 
Chapter 4.3
Chapter 4.3Chapter 4.3
Chapter 4.3
 
Chapter 8.1
Chapter 8.1Chapter 8.1
Chapter 8.1
 
Chapter 7.2
Chapter 7.2Chapter 7.2
Chapter 7.2
 
정몽준 서울시장 새누리당 후보 정책 공약 _ 33한서울88한경제
정몽준 서울시장 새누리당 후보 정책 공약 _ 33한서울88한경제 정몽준 서울시장 새누리당 후보 정책 공약 _ 33한서울88한경제
정몽준 서울시장 새누리당 후보 정책 공약 _ 33한서울88한경제
 
Chapter 11.1
Chapter 11.1Chapter 11.1
Chapter 11.1
 
Chapter 11.3
Chapter 11.3Chapter 11.3
Chapter 11.3
 
Cyberbullying by alex pitcher
Cyberbullying by alex pitcherCyberbullying by alex pitcher
Cyberbullying by alex pitcher
 
Presentacion leydi perezI
Presentacion leydi perezIPresentacion leydi perezI
Presentacion leydi perezI
 
Dangers to social media
Dangers to social mediaDangers to social media
Dangers to social media
 
Smart phone. addiction. blindness
Smart phone. addiction. blindnessSmart phone. addiction. blindness
Smart phone. addiction. blindness
 

Similar to Chapter 3.2

Java basics and java variables
Java basics and java variablesJava basics and java variables
Java basics and java variables
Pushpendra Tyagi
 
Esoft Metro Campus - Programming with C++
Esoft Metro Campus - Programming with C++Esoft Metro Campus - Programming with C++
Esoft Metro Campus - Programming with C++
Rasan Samarasinghe
 
C# language basics (Visual Studio)
C# language basics (Visual Studio) C# language basics (Visual Studio)
C# language basics (Visual Studio)
rnkhan
 
C# language basics (Visual studio)
C# language basics (Visual studio)C# language basics (Visual studio)
C# language basics (Visual studio)
rnkhan
 
Java: Primitive Data Types
Java: Primitive Data TypesJava: Primitive Data Types
Java: Primitive Data Types
Tareq Hasan
 
Java Programming
Java Programming Java Programming
Java Programming
RubaNagarajan
 
Java works on different platforms (Windows, Mac, Linux, Raspberry Pi, etc.) I...
Java works on different platforms (Windows, Mac, Linux, Raspberry Pi, etc.) I...Java works on different platforms (Windows, Mac, Linux, Raspberry Pi, etc.) I...
Java works on different platforms (Windows, Mac, Linux, Raspberry Pi, etc.) I...
GANESHBABUVelu
 
Esoft Metro Campus - Certificate in c / c++ programming
Esoft Metro Campus - Certificate in c / c++ programmingEsoft Metro Campus - Certificate in c / c++ programming
Esoft Metro Campus - Certificate in c / c++ programming
Rasan Samarasinghe
 
Lecture2_MCS4_Evening.pptx
Lecture2_MCS4_Evening.pptxLecture2_MCS4_Evening.pptx
Lecture2_MCS4_Evening.pptx
SaqlainYaqub1
 
Introduction to Java
Introduction to JavaIntroduction to Java
Introduction to Java
Ashita Agrawal
 
java tutorial 2
 java tutorial 2 java tutorial 2
java tutorial 2
Tushar Desarda
 
Introduction to-programming
Introduction to-programmingIntroduction to-programming
Introduction to-programming
BG Java EE Course
 
Md03 - part3
Md03 - part3Md03 - part3
Md03 - part3
Rakesh Madugula
 
Identifiers, keywords and types
Identifiers, keywords and typesIdentifiers, keywords and types
Identifiers, keywords and types
Daman Toor
 
vb.net.pdf
vb.net.pdfvb.net.pdf
vb.net.pdf
VimalSangar1
 
unit 1 (1).pptx
unit 1 (1).pptxunit 1 (1).pptx
unit 1 (1).pptx
PriyadarshiniS28
 
JavaScript.pptx
JavaScript.pptxJavaScript.pptx
JavaScript.pptx
Govardhan Bhavani
 
Lecture - 3 Variables-data type_operators_oops concept
Lecture - 3 Variables-data type_operators_oops conceptLecture - 3 Variables-data type_operators_oops concept
Lecture - 3 Variables-data type_operators_oops concept
manish kumar
 
Gnu octave help book 02 of 02
Gnu octave help book 02 of 02Gnu octave help book 02 of 02
Gnu octave help book 02 of 02
Arun Umrao
 
Notes for GNU Octave - Numerical Programming - for Students - 02 of 02 by aru...
Notes for GNU Octave - Numerical Programming - for Students - 02 of 02 by aru...Notes for GNU Octave - Numerical Programming - for Students - 02 of 02 by aru...
Notes for GNU Octave - Numerical Programming - for Students - 02 of 02 by aru...
ssuserd6b1fd
 

Similar to Chapter 3.2 (20)

Java basics and java variables
Java basics and java variablesJava basics and java variables
Java basics and java variables
 
Esoft Metro Campus - Programming with C++
Esoft Metro Campus - Programming with C++Esoft Metro Campus - Programming with C++
Esoft Metro Campus - Programming with C++
 
C# language basics (Visual Studio)
C# language basics (Visual Studio) C# language basics (Visual Studio)
C# language basics (Visual Studio)
 
C# language basics (Visual studio)
C# language basics (Visual studio)C# language basics (Visual studio)
C# language basics (Visual studio)
 
Java: Primitive Data Types
Java: Primitive Data TypesJava: Primitive Data Types
Java: Primitive Data Types
 
Java Programming
Java Programming Java Programming
Java Programming
 
Java works on different platforms (Windows, Mac, Linux, Raspberry Pi, etc.) I...
Java works on different platforms (Windows, Mac, Linux, Raspberry Pi, etc.) I...Java works on different platforms (Windows, Mac, Linux, Raspberry Pi, etc.) I...
Java works on different platforms (Windows, Mac, Linux, Raspberry Pi, etc.) I...
 
Esoft Metro Campus - Certificate in c / c++ programming
Esoft Metro Campus - Certificate in c / c++ programmingEsoft Metro Campus - Certificate in c / c++ programming
Esoft Metro Campus - Certificate in c / c++ programming
 
Lecture2_MCS4_Evening.pptx
Lecture2_MCS4_Evening.pptxLecture2_MCS4_Evening.pptx
Lecture2_MCS4_Evening.pptx
 
Introduction to Java
Introduction to JavaIntroduction to Java
Introduction to Java
 
java tutorial 2
 java tutorial 2 java tutorial 2
java tutorial 2
 
Introduction to-programming
Introduction to-programmingIntroduction to-programming
Introduction to-programming
 
Md03 - part3
Md03 - part3Md03 - part3
Md03 - part3
 
Identifiers, keywords and types
Identifiers, keywords and typesIdentifiers, keywords and types
Identifiers, keywords and types
 
vb.net.pdf
vb.net.pdfvb.net.pdf
vb.net.pdf
 
unit 1 (1).pptx
unit 1 (1).pptxunit 1 (1).pptx
unit 1 (1).pptx
 
JavaScript.pptx
JavaScript.pptxJavaScript.pptx
JavaScript.pptx
 
Lecture - 3 Variables-data type_operators_oops concept
Lecture - 3 Variables-data type_operators_oops conceptLecture - 3 Variables-data type_operators_oops concept
Lecture - 3 Variables-data type_operators_oops concept
 
Gnu octave help book 02 of 02
Gnu octave help book 02 of 02Gnu octave help book 02 of 02
Gnu octave help book 02 of 02
 
Notes for GNU Octave - Numerical Programming - for Students - 02 of 02 by aru...
Notes for GNU Octave - Numerical Programming - for Students - 02 of 02 by aru...Notes for GNU Octave - Numerical Programming - for Students - 02 of 02 by aru...
Notes for GNU Octave - Numerical Programming - for Students - 02 of 02 by aru...
 

More from sotlsoc

Chapter 2.0 new
Chapter 2.0 newChapter 2.0 new
Chapter 2.0 new
sotlsoc
 
Chapter 1.0 new
Chapter 1.0 newChapter 1.0 new
Chapter 1.0 new
sotlsoc
 
Chapter 3.0 new
Chapter 3.0 newChapter 3.0 new
Chapter 3.0 new
sotlsoc
 
Chapter 6.5 new
Chapter 6.5 newChapter 6.5 new
Chapter 6.5 new
sotlsoc
 
Chapter 10.3
Chapter 10.3Chapter 10.3
Chapter 10.3
sotlsoc
 
Chapter 11.4
Chapter 11.4Chapter 11.4
Chapter 11.4
sotlsoc
 
Chapter 11.5
Chapter 11.5Chapter 11.5
Chapter 11.5
sotlsoc
 
Chapter 11.2
Chapter 11.2Chapter 11.2
Chapter 11.2
sotlsoc
 
Chapter 11.0
Chapter 11.0Chapter 11.0
Chapter 11.0
sotlsoc
 
Chapter 10.1
Chapter 10.1Chapter 10.1
Chapter 10.1
sotlsoc
 
Chapter 8.0
Chapter 8.0Chapter 8.0
Chapter 8.0
sotlsoc
 
Chapter 10.0
Chapter 10.0Chapter 10.0
Chapter 10.0
sotlsoc
 
Chapter 9.4
Chapter 9.4Chapter 9.4
Chapter 9.4
sotlsoc
 
Chapter 9.1
Chapter 9.1Chapter 9.1
Chapter 9.1
sotlsoc
 
Chapter 9.0
Chapter 9.0Chapter 9.0
Chapter 9.0
sotlsoc
 
Chapter 9.2
Chapter 9.2Chapter 9.2
Chapter 9.2
sotlsoc
 
Chapter 8.3
Chapter 8.3Chapter 8.3
Chapter 8.3
sotlsoc
 
Chapter 8.2
Chapter 8.2Chapter 8.2
Chapter 8.2
sotlsoc
 
Chapter 5.2
Chapter 5.2Chapter 5.2
Chapter 5.2
sotlsoc
 
Chapter 7.4
Chapter 7.4Chapter 7.4
Chapter 7.4
sotlsoc
 

More from sotlsoc (20)

Chapter 2.0 new
Chapter 2.0 newChapter 2.0 new
Chapter 2.0 new
 
Chapter 1.0 new
Chapter 1.0 newChapter 1.0 new
Chapter 1.0 new
 
Chapter 3.0 new
Chapter 3.0 newChapter 3.0 new
Chapter 3.0 new
 
Chapter 6.5 new
Chapter 6.5 newChapter 6.5 new
Chapter 6.5 new
 
Chapter 10.3
Chapter 10.3Chapter 10.3
Chapter 10.3
 
Chapter 11.4
Chapter 11.4Chapter 11.4
Chapter 11.4
 
Chapter 11.5
Chapter 11.5Chapter 11.5
Chapter 11.5
 
Chapter 11.2
Chapter 11.2Chapter 11.2
Chapter 11.2
 
Chapter 11.0
Chapter 11.0Chapter 11.0
Chapter 11.0
 
Chapter 10.1
Chapter 10.1Chapter 10.1
Chapter 10.1
 
Chapter 8.0
Chapter 8.0Chapter 8.0
Chapter 8.0
 
Chapter 10.0
Chapter 10.0Chapter 10.0
Chapter 10.0
 
Chapter 9.4
Chapter 9.4Chapter 9.4
Chapter 9.4
 
Chapter 9.1
Chapter 9.1Chapter 9.1
Chapter 9.1
 
Chapter 9.0
Chapter 9.0Chapter 9.0
Chapter 9.0
 
Chapter 9.2
Chapter 9.2Chapter 9.2
Chapter 9.2
 
Chapter 8.3
Chapter 8.3Chapter 8.3
Chapter 8.3
 
Chapter 8.2
Chapter 8.2Chapter 8.2
Chapter 8.2
 
Chapter 5.2
Chapter 5.2Chapter 5.2
Chapter 5.2
 
Chapter 7.4
Chapter 7.4Chapter 7.4
Chapter 7.4
 

Recently uploaded

REASIGNACION 2024 UGEL CHUPACA 2024 UGEL CHUPACA.pdf
REASIGNACION 2024 UGEL CHUPACA 2024 UGEL CHUPACA.pdfREASIGNACION 2024 UGEL CHUPACA 2024 UGEL CHUPACA.pdf
REASIGNACION 2024 UGEL CHUPACA 2024 UGEL CHUPACA.pdf
giancarloi8888
 
Accounting for Restricted Grants When and How To Record Properly
Accounting for Restricted Grants  When and How To Record ProperlyAccounting for Restricted Grants  When and How To Record Properly
Accounting for Restricted Grants When and How To Record Properly
TechSoup
 
Haunted Houses by H W Longfellow for class 10
Haunted Houses by H W Longfellow for class 10Haunted Houses by H W Longfellow for class 10
Haunted Houses by H W Longfellow for class 10
nitinpv4ai
 
KHUSWANT SINGH.pptx ALL YOU NEED TO KNOW ABOUT KHUSHWANT SINGH
KHUSWANT SINGH.pptx ALL YOU NEED TO KNOW ABOUT KHUSHWANT SINGHKHUSWANT SINGH.pptx ALL YOU NEED TO KNOW ABOUT KHUSHWANT SINGH
KHUSWANT SINGH.pptx ALL YOU NEED TO KNOW ABOUT KHUSHWANT SINGH
shreyassri1208
 
Gender and Mental Health - Counselling and Family Therapy Applications and In...
Gender and Mental Health - Counselling and Family Therapy Applications and In...Gender and Mental Health - Counselling and Family Therapy Applications and In...
Gender and Mental Health - Counselling and Family Therapy Applications and In...
PsychoTech Services
 
A Free 200-Page eBook ~ Brain and Mind Exercise.pptx
A Free 200-Page eBook ~ Brain and Mind Exercise.pptxA Free 200-Page eBook ~ Brain and Mind Exercise.pptx
A Free 200-Page eBook ~ Brain and Mind Exercise.pptx
OH TEIK BIN
 
Data Structure using C by Dr. K Adisesha .ppsx
Data Structure using C by Dr. K Adisesha .ppsxData Structure using C by Dr. K Adisesha .ppsx
Data Structure using C by Dr. K Adisesha .ppsx
Prof. Dr. K. Adisesha
 
Geography as a Discipline Chapter 1 __ Class 11 Geography NCERT _ Class Notes...
Geography as a Discipline Chapter 1 __ Class 11 Geography NCERT _ Class Notes...Geography as a Discipline Chapter 1 __ Class 11 Geography NCERT _ Class Notes...
Geography as a Discipline Chapter 1 __ Class 11 Geography NCERT _ Class Notes...
ImMuslim
 
Electric Fetus - Record Store Scavenger Hunt
Electric Fetus - Record Store Scavenger HuntElectric Fetus - Record Store Scavenger Hunt
Electric Fetus - Record Store Scavenger Hunt
RamseyBerglund
 
Educational Technology in the Health Sciences
Educational Technology in the Health SciencesEducational Technology in the Health Sciences
Educational Technology in the Health Sciences
Iris Thiele Isip-Tan
 
مصحف القراءات العشر أعد أحرف الخلاف سمير بسيوني.pdf
مصحف القراءات العشر   أعد أحرف الخلاف سمير بسيوني.pdfمصحف القراءات العشر   أعد أحرف الخلاف سمير بسيوني.pdf
مصحف القراءات العشر أعد أحرف الخلاف سمير بسيوني.pdf
سمير بسيوني
 
Elevate Your Nonprofit's Online Presence_ A Guide to Effective SEO Strategies...
Elevate Your Nonprofit's Online Presence_ A Guide to Effective SEO Strategies...Elevate Your Nonprofit's Online Presence_ A Guide to Effective SEO Strategies...
Elevate Your Nonprofit's Online Presence_ A Guide to Effective SEO Strategies...
TechSoup
 
Bossa N’ Roll Records by Ismael Vazquez.
Bossa N’ Roll Records by Ismael Vazquez.Bossa N’ Roll Records by Ismael Vazquez.
Bossa N’ Roll Records by Ismael Vazquez.
IsmaelVazquez38
 
Skimbleshanks-The-Railway-Cat by T S Eliot
Skimbleshanks-The-Railway-Cat by T S EliotSkimbleshanks-The-Railway-Cat by T S Eliot
Skimbleshanks-The-Railway-Cat by T S Eliot
nitinpv4ai
 
SWOT analysis in the project Keeping the Memory @live.pptx
SWOT analysis in the project Keeping the Memory @live.pptxSWOT analysis in the project Keeping the Memory @live.pptx
SWOT analysis in the project Keeping the Memory @live.pptx
zuzanka
 
Level 3 NCEA - NZ: A Nation In the Making 1872 - 1900 SML.ppt
Level 3 NCEA - NZ: A  Nation In the Making 1872 - 1900 SML.pptLevel 3 NCEA - NZ: A  Nation In the Making 1872 - 1900 SML.ppt
Level 3 NCEA - NZ: A Nation In the Making 1872 - 1900 SML.ppt
Henry Hollis
 
220711130083 SUBHASHREE RAKSHIT Internet resources for social science
220711130083 SUBHASHREE RAKSHIT  Internet resources for social science220711130083 SUBHASHREE RAKSHIT  Internet resources for social science
220711130083 SUBHASHREE RAKSHIT Internet resources for social science
Kalna College
 
Oliver Asks for More by Charles Dickens (9)
Oliver Asks for More by Charles Dickens (9)Oliver Asks for More by Charles Dickens (9)
Oliver Asks for More by Charles Dickens (9)
nitinpv4ai
 
RESULTS OF THE EVALUATION QUESTIONNAIRE.pptx
RESULTS OF THE EVALUATION QUESTIONNAIRE.pptxRESULTS OF THE EVALUATION QUESTIONNAIRE.pptx
RESULTS OF THE EVALUATION QUESTIONNAIRE.pptx
zuzanka
 
How to Setup Default Value for a Field in Odoo 17
How to Setup Default Value for a Field in Odoo 17How to Setup Default Value for a Field in Odoo 17
How to Setup Default Value for a Field in Odoo 17
Celine George
 

Recently uploaded (20)

REASIGNACION 2024 UGEL CHUPACA 2024 UGEL CHUPACA.pdf
REASIGNACION 2024 UGEL CHUPACA 2024 UGEL CHUPACA.pdfREASIGNACION 2024 UGEL CHUPACA 2024 UGEL CHUPACA.pdf
REASIGNACION 2024 UGEL CHUPACA 2024 UGEL CHUPACA.pdf
 
Accounting for Restricted Grants When and How To Record Properly
Accounting for Restricted Grants  When and How To Record ProperlyAccounting for Restricted Grants  When and How To Record Properly
Accounting for Restricted Grants When and How To Record Properly
 
Haunted Houses by H W Longfellow for class 10
Haunted Houses by H W Longfellow for class 10Haunted Houses by H W Longfellow for class 10
Haunted Houses by H W Longfellow for class 10
 
KHUSWANT SINGH.pptx ALL YOU NEED TO KNOW ABOUT KHUSHWANT SINGH
KHUSWANT SINGH.pptx ALL YOU NEED TO KNOW ABOUT KHUSHWANT SINGHKHUSWANT SINGH.pptx ALL YOU NEED TO KNOW ABOUT KHUSHWANT SINGH
KHUSWANT SINGH.pptx ALL YOU NEED TO KNOW ABOUT KHUSHWANT SINGH
 
Gender and Mental Health - Counselling and Family Therapy Applications and In...
Gender and Mental Health - Counselling and Family Therapy Applications and In...Gender and Mental Health - Counselling and Family Therapy Applications and In...
Gender and Mental Health - Counselling and Family Therapy Applications and In...
 
A Free 200-Page eBook ~ Brain and Mind Exercise.pptx
A Free 200-Page eBook ~ Brain and Mind Exercise.pptxA Free 200-Page eBook ~ Brain and Mind Exercise.pptx
A Free 200-Page eBook ~ Brain and Mind Exercise.pptx
 
Data Structure using C by Dr. K Adisesha .ppsx
Data Structure using C by Dr. K Adisesha .ppsxData Structure using C by Dr. K Adisesha .ppsx
Data Structure using C by Dr. K Adisesha .ppsx
 
Geography as a Discipline Chapter 1 __ Class 11 Geography NCERT _ Class Notes...
Geography as a Discipline Chapter 1 __ Class 11 Geography NCERT _ Class Notes...Geography as a Discipline Chapter 1 __ Class 11 Geography NCERT _ Class Notes...
Geography as a Discipline Chapter 1 __ Class 11 Geography NCERT _ Class Notes...
 
Electric Fetus - Record Store Scavenger Hunt
Electric Fetus - Record Store Scavenger HuntElectric Fetus - Record Store Scavenger Hunt
Electric Fetus - Record Store Scavenger Hunt
 
Educational Technology in the Health Sciences
Educational Technology in the Health SciencesEducational Technology in the Health Sciences
Educational Technology in the Health Sciences
 
مصحف القراءات العشر أعد أحرف الخلاف سمير بسيوني.pdf
مصحف القراءات العشر   أعد أحرف الخلاف سمير بسيوني.pdfمصحف القراءات العشر   أعد أحرف الخلاف سمير بسيوني.pdf
مصحف القراءات العشر أعد أحرف الخلاف سمير بسيوني.pdf
 
Elevate Your Nonprofit's Online Presence_ A Guide to Effective SEO Strategies...
Elevate Your Nonprofit's Online Presence_ A Guide to Effective SEO Strategies...Elevate Your Nonprofit's Online Presence_ A Guide to Effective SEO Strategies...
Elevate Your Nonprofit's Online Presence_ A Guide to Effective SEO Strategies...
 
Bossa N’ Roll Records by Ismael Vazquez.
Bossa N’ Roll Records by Ismael Vazquez.Bossa N’ Roll Records by Ismael Vazquez.
Bossa N’ Roll Records by Ismael Vazquez.
 
Skimbleshanks-The-Railway-Cat by T S Eliot
Skimbleshanks-The-Railway-Cat by T S EliotSkimbleshanks-The-Railway-Cat by T S Eliot
Skimbleshanks-The-Railway-Cat by T S Eliot
 
SWOT analysis in the project Keeping the Memory @live.pptx
SWOT analysis in the project Keeping the Memory @live.pptxSWOT analysis in the project Keeping the Memory @live.pptx
SWOT analysis in the project Keeping the Memory @live.pptx
 
Level 3 NCEA - NZ: A Nation In the Making 1872 - 1900 SML.ppt
Level 3 NCEA - NZ: A  Nation In the Making 1872 - 1900 SML.pptLevel 3 NCEA - NZ: A  Nation In the Making 1872 - 1900 SML.ppt
Level 3 NCEA - NZ: A Nation In the Making 1872 - 1900 SML.ppt
 
220711130083 SUBHASHREE RAKSHIT Internet resources for social science
220711130083 SUBHASHREE RAKSHIT  Internet resources for social science220711130083 SUBHASHREE RAKSHIT  Internet resources for social science
220711130083 SUBHASHREE RAKSHIT Internet resources for social science
 
Oliver Asks for More by Charles Dickens (9)
Oliver Asks for More by Charles Dickens (9)Oliver Asks for More by Charles Dickens (9)
Oliver Asks for More by Charles Dickens (9)
 
RESULTS OF THE EVALUATION QUESTIONNAIRE.pptx
RESULTS OF THE EVALUATION QUESTIONNAIRE.pptxRESULTS OF THE EVALUATION QUESTIONNAIRE.pptx
RESULTS OF THE EVALUATION QUESTIONNAIRE.pptx
 
How to Setup Default Value for a Field in Odoo 17
How to Setup Default Value for a Field in Odoo 17How to Setup Default Value for a Field in Odoo 17
How to Setup Default Value for a Field in Odoo 17
 

Chapter 3.2

  • 1. IMPLEMENTING ASSIGNMENT STATEMENTS AND EXPRESSION Chapter 3.2:
  • 2. Assignment Statement  An assignment statement changes the value of a variable  The assignment operator is the = sign  Syntax for assignment statement: variable = expression; • E.g: • The value that was in total is overwritten • You can only assign a value to a variable that is consistent with the variable's declared type • See Geometry.java total = 55;
  • 3. Assignment Statement //******************************************************************** // Geometry.java Author: Lewis/Loftus // // Demonstrates the use of an assignment statement to change the // value stored in a variable. //******************************************************************** public class Geometry { //----------------------------------------------------------------- // Prints the number of sides of several geometric shapes. //----------------------------------------------------------------- public static void main (String[] args) { int sides = 7; // declaration with initialization System.out.println ("A heptagon has " + sides + " sides."); sides = 10; // assignment statement System.out.println ("A decagon has " + sides + " sides."); sides = 12; System.out.println ("A dodecagon has " + sides + " sides."); } }
  • 4. Assignment Statement //******************************************************************** // Geometry.java Author: Lewis/Loftus // // Demonstrates the use of an assignment statement to change the // value stored in a variable. //******************************************************************** public class Geometry { //----------------------------------------------------------------- // Prints the number of sides of several geometric shapes. //----------------------------------------------------------------- public static void main (String[] args) { int sides = 7; // declaration with initialization System.out.println ("A heptagon has " + sides + " sides."); sides = 10; // assignment statement System.out.println ("A decagon has " + sides + " sides."); sides = 12; System.out.println ("A dodecagon has " + sides + " sides."); } } Output A heptagon has 7 sides. A decagon has 10 sides. a dodecagon has 12 sides.
  • 5. Declaring, Initializing and Assignment j=k=x=2; equivalent to: x=2; k=x; j=k;  Declare and initialize. E.g: int x = 1; int i =1, j=2;
  • 6. Uninitialized Variables  Error: An Uninitialized Object Variable int luckyNumber; System.out.println(luckyNumber); // ERROR - uninitialized variable
  • 7. Constants  A constant is an identifier that is similar to a variable except that it holds the same value during its entire existence  As the name implies, it is constant, not variable  The compiler will issue an error if you try to change the value of a constant
  • 8. Constants  Permanent data that never change during program execution  Example:  = 3.14159  Declared by using the reserved word final.  Initialized when it is declared.  Syntax: final datatype CONSTANTNAME = value  Example : final double CENTIMETERS_PER_INCH = 2.54; final int NO_OF_STUDENTS = 20; final char BLANK = ' '; final double PAY_RATE = 15.75;
  • 9. Data Types  A set of values together with a set of operations.
  • 10. Primitive Data Types • The primitive data type are the fundamental data types in Java.
  • 11. Primitive Data Types • Integral data types (deals with integers, or numbers without a decimal part):
  • 12. Primitive Data Types  Floating-point data types (deals with decimal numbers):  float  double  boolean (deals with logical values):  True  False
  • 13. Values and Memory Allocation for Integral and Floating-point Data Types
  • 14. Characters  A char variable stores a single character  Character literals are delimited by single quotes: 'a' 'X' '7' '$' ',' 'n'  Example declarations: char topGrade = 'A'; char terminator = ';', separator = ' ';  Note the difference between a primitive character variable, which holds only one character, and a String object, which can hold multiple characters
  • 15. Characters  A character set is an ordered list of characters, with each character corresponding to a unique number  A char variable in Java can store any character from the Unicode character set  The Unicode character set uses sixteen bits per character, allowing for 65,536 unique characters  It is an international character set, containing symbols and characters from many world languages
  • 16. Characters  The ASCII character set is older and smaller than Unicode, but is still quite popular  The ASCII characters are a subset of the Unicode character set, including: uppercase letters lowercase letters punctuation digits special symbols control characters A, B, C, … a, b, c, … period, semi-colon, … 0, 1, 2, … &, |, , … carriage return, tab, ...
  • 17. Boolean  A boolean value represents a true or false condition  The reserved words true and false are the only valid values for a boolean type boolean done = false;  A boolean variable can also be used to represent any two states, such as a light bulb being on or off