❮ Previous Next ❯

Java Literals

A literal is nothing but a value which is stored into a variable in the program.

Example

int x =1520;
char c =”x”;
boolen b =false;

In the above statement the right hand side values are called literals. java support different types of literals such as:

  1. Integer literal
  2. Floating literal
  3. Character literal
  4. String literal
  5. Boolean literal

Integer literal

int x =25; // The number 25 in decimal
int y =031; // The number 25 in octal
int z =0x19; // The number 25 is in hexadecimal

Floating Literal

Floating literal represent the decimal value with a fractional component. Like 5.2,0.0004,2.15 etc .while writing the floating literals we can use E or e for scientific notation, F or f for float literal and D or d for double literal

Example

double x =345.67;

Character Literals

Character literals represents the following

Character literals should be enclosed in single quotation mark.

String Literals

String literals represent objects of string class. For example vivtech, lakshya, rajeshKumar, BQ1210, etc comes under string literals which can be directly stored into a string object.

Boolean Literals

Boolean literals represent only two values such as True and False that means we can store either true or false into a boolean type variables.

❮ Previous Next ❯

Follow Us




  Tutorials

Popular Links

Contact Us

address Plot No-741,2ND Floor
Opp. Bhagabati Temple,Jayadev Vihar
      Bhubaneswar-751013
      Email: info@silantechnology.com
      Phone: 0674-2361252
address
39877, sundale dr, apt#101, Fremont, California 94538, USA
       Phone: +1(262)388-7619

facebook twitter google linked in

© 2018 Silan Technology. All Rights Reserved