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


Download 0.82 Mb.
Pdf ko'rish
bet15/95
Sana09.01.2022
Hajmi0.82 Mb.
#261112
1   ...   11   12   13   14   15   16   17   18   ...   95
Bog'liq
Java Programming For Beginners - A Simple Start to Java Programming ( PDFDrive )

Java Literals
A  literal  in  Java  is  a  source  code  representation  of  a  settled  worth.  They  are  spoken  to
specifically in the code without any calculation. Literals can be appointed to any primitive
sort variable. Case in point:
byte x = 86;
char x = “a”
int, byte, short and long can be communicated in hexadecimal(base 16), decimal(base 10)
or octal(base 8) number frameworks too. Prefix 0 is utilized to show octal while prefix 0x
demonstrates  hexadecimal  when  utilizing  these  number  frameworks  for  literals.  For
example,
int numd = 134;
int numo = 0243;
int numx = 0x95;
String  literals  in  Java  are  determined  like  they  are  in  most  different  programming
languages  by  encasing  a  grouping  of  characters  between  a  couple  of  twofold  quotes.
Illustrations of string literals are:
“Hi Everyone” “two\nlines” “"these characters are inside quotes"”
String sorts of literals can contain any Unicode characters. For instance:
String news = “\u0001”
You can also use escape sequences with Java. Here is a list of escape sequences that you
can use.
Double quote - "
Carriage return (0x0d) - \r
Newline (0x0a) - \n
Single quote - '
Backspace (0x08) - \b
Formfeed (0x0c) - \f


Tab - \t
Space (0x20) - \s
Octal character (ddd) - \ddd
Backslash - \
Hexadecimal UNICODE character (xxxx) - \uxxxx




Download 0.82 Mb.

Do'stlaringiz bilan baham:
1   ...   11   12   13   14   15   16   17   18   ...   95




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