Java: Java Programming For Beginners a simple Start To Java Programming (Written By a software Engineer)


Download 0.82 Mb.
Pdf ko'rish
bet84/95
Sana09.01.2022
Hajmi0.82 Mb.
#261112
1   ...   80   81   82   83   84   85   86   87   ...   95
Bog'liq
Java Programming For Beginners - A Simple Start to Java Programming ( PDFDrive )

String Data Type
A  string  can  simply  be  described  as  a  collection  of  characters.  Whenever  you  declare
character(s) within quotes, the system interprets as a string. Sample strings include:
‘Hello World!’
“Hello World!”
However, if you want to include quotes as characters in the string, then you must add ‘\’
before the character. Sample string:


‘You\’re Welcome’
“You\’re Welcome”
JavaScript also supports other escape sequences like \t for tab and \n for newline.
Boolean Data Type
The Boolean data type is a binary data type and return either true or false. These operators
are commonly used to indicate results of comparisons. For example,
10 > 5 will give ‘true’ while 5 > 10 will give ‘false’.
Operations on Number data Type
In  order  to  perform  calculations,  operators  are  used.  JavaScript  supports  all  the  basic
operators and the operator precedence is as follows:
Addition and subtraction have the same precedence.
Multiplication and division have the same precedence.
The  precedence  of  multiplication  and  division  is  higher  than  that  of  addition  and
subtraction.
If  an  expression  contains  several  operators  of  the  same  precedence,  then  the
expression is evaluated from left to right.
In  addition  to  the  basic  operators,  JavaScript  also  supports  modulo  (%)  operator.  This
operator  performs  division  and  returns  the  remainder  as  result.  For  example,  23%7  is
equal to 2.
Unary Operators
While operators like addition and subtraction need to operands to execute, some operators
require only one. An example of such operators is typeof, which returns the datatype of the
data. For example, typeof 12 returns ‘number’. Please note that ‘+’ and ‘-‘ can also be used
as unary operators. This is the case when they are used to specify the sign of a number.



Download 0.82 Mb.

Do'stlaringiz bilan baham:
1   ...   80   81   82   83   84   85   86   87   ...   95




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling