Skip to main content

Literals in JAVA notes

Literals:

(Java is case sensitive language except some cases:
l or L (explicit conversion for long)
b or B (for binary form representaion preceded by 0 ex:0B or 0b)
f or F (for denoting explicitly float )
A-F or a-f (range in Hexadecimal Notation)
x or X (for denoting Hexa form preceded by 0 : ex 0X or 0x)
)


A) Integer Literals:

i) Decimal Representation:10 ,20 ,40


ii) Hexadecimal Literals:0x123A , 0x 343F


iii) Binary Representation: 0b101110

iv) Octal Representation: 0117, 01121

v) (underscore Representation): 1_2__3 ,12_3,1_2_3_4

_ is just a separator which is removed by the compiler.
NOTE:
1.underscore should come only between the numbers.
2. We can have more than one underscore also in between the numbers.
3. Compiler skips all the underscore and represents the integer literals in the actual form.
It means _ representation is provided for the programmers to represent large number easily.



INTEGER Literals are having size 4 byte.
All the integral literals are by default int type.
All the Floating point Literals are of double type by default.
Floating point Literals are having 8-byte size.


B) Floating Point Literals :

i)By use of Decimal point:--2.5, 5.4,-98.2

ii) By use of Exponent:3.4E01,4.2E-23

iii) BY use of Underscore:- 34.3_2,3_4_2.41

not possible :---> ex. 34_.4








General Knowledge:
Float
Double

1.Single Point Precision.
1.Double point Precision.

2. Up to 7 points accurate
2. Up to 15 points Accurate.
3.-3.4e+38 to 3.4e38
3. -1.79e308 to 1.79e308
Some wrong floating Representation:
float f=012.1;
float f=0x12.3f;
float f=0x12.3;

some Correct Floating representation:
float f=012.1f;
float f=012;
float f=0x12;

RULE:
1. byte->short->int->long->float->double.

2. char->int



C) Character Literals: .

1) Character in single quote:
ex. char c=’d’;
2. By intergral Literals:
char c=10;
3.By unicode representation :
ex char c=\u(XXXX)

where XXXX is hexadecimal Unicode representation.
4.Using Escape Sequence :
in JAVA there is 8 escape sequence :
\n new line
\t tab
\b backspace
\f form feed
\r carriage return
\’ (‘)
\” (“)
\\ (\)

D) String Literals:

i) Represented using double quotes.
Ex “hello”,”test”
_________________________

Comments

Popular posts from this blog

python program to Print Starting Series OF Indian Mobile Number for a State or operator or both

import requests import urllib.request import time from bs4 import BeautifulSoup as bs import re url = ' https://en.wikipedia.org/wiki/Mobile_telephone_numbering_in_India' state_to_extract = "UE" #if set to None all state is considered telecom_to_extracted = None #if set to none all operator from particular city is extracted response = requests . get(url) print (response) soup = bs(response . text, "html.parser" ) one_a_tag = soup . findAll( 'tr' )[ 35 :] lst = [] for k in one_a_tag: s = k . findAll( 'td' ) limit = len (s) i = 0 while True : if i == limit: break no = s[i] . text i += 1 if i == limit: break operator = s[i] . text i += 1 if i == limit: break state = s[i] . text i += 1 if i == limit: break res = f "{no} {operator} {state}" if state_to_extract is None : if telecom_to_extracted is None : lst . append(no) elif telecom_to_e...

13 websites to register your free domain

Register your Free Domain Now!! 1)  .tk Dot TK is a FREE domain registry for websites on the Internet. It has exactly the same power as other domain extensions, but it’s free! Because it’s free, millions of others have been using .TK domains since 2001 – which makes .TK powerful and very recognizable.  Your website will be like www.yourdomainname.tk . It is free for 1 year. It’s a ccTLD domain whixh having the abbreviation  Tokelau. To create a .tk domain, Visit   www.dot.tk 2) co.cc Co.cc is completely free domain which is mostly used by blogspot bloggers because of it’s easy to use DNS system. Creating a co.cc for blogger is simple ( for instructions- “click here”). Your website will be like www.yourdomainname.co.cc . To create a .co.cc domain, visit www.co.cc 3)   co.nr co.nr is too like co.cc. Your website will be like  www.yourdomainname.co.nr . You can add it for blogger also.. To create a .co.cc domain, vi...

How to Put Google Adsense Below Post Title in Blogger?

Adsense is used by majority of expert bloggers for their website monetization because it is a cookie based contextual advertising system that shows targeted ads relevant to the content and reader. As bloggers are paid on per click basis, they try various ad placements on the blog to  increase the revenue  and get maximum clicks on the ad units. Well, on some blogs, you might have seen Adsense ad units placed below the post title. Do you know why? It is because the area just below the post title gets the most exposure and is the best place to put AdSense ad units to increase  Click Through Rate (CTR). Even though ads below post title work like a charm but this doesn’t mean that it will work for you as well. If you want to find out the best AdSense ads placement for your blog, try experimenting by placing ads at various locations such as header, sidebar, footer, etc. You can try other  blog monetization methods  as well to effectively monetize y...

SEEDR : SAVIOUR OF TORRENT DOWNLOADING

Seedr is a next-generation product aiming to bring the torrent experience to a whole new level. Although torrents are not exactly legal or safe, but they have now become part and parcel of our online life now. So, to access them in the fastest and safest way possible we have Seedr. Features: Stream movies, music, and books on any device With top-in-class streaming technology, Seedr allows you to watch movies, listen to music, or read anything in your torrent library directly from the cloud on any device. Private and safe Seedr has high-level transport encryption to protect your privacy, and there is no need to worry about malware, viruses, or outside tracking – Seedr is the barrier protecting you. Very fast Seedr runs on a high-speed backbone and can fetch torrents to the cloud within several minutes down to several seconds. Fetch and stream torrents on your mobile device If you’ve ever tried using torrents on either tablet or phone, you’d quickly find out how impracti...

Mafia 2 PC Game Download Free ISO Full DLC

Mafia 2 PC Game Review: Mafia 2 Plaza free download game is first person shooting game released for pc and PlayStation 3. PC Game game mafia II is the second  Sequel of Mafia Series Launched  By Daniel Vávra in 2010. Mafia 2 is an open world map game. Just like  GTA IV For PC easy to install and run  on windows 10 64 bit. Game story is based on gang war in which the mafia runs the city and do all the crimes.  Gangs Run The City however  the player plays the important role in the game to be a cop in the game.Best weapons and New Graphics In mafia II Game For PC, World Wide Multiplayer Game For PC Play it online low system Requirements. PROOF :- Mafia 2 Complete Free Download. And find out the eve dance in the game. The game has been played by most of the Pro Games.The game can be played in Core 2 Duo mafia system requirements. Download Game for pc direct single link free.  Gta v download full game and install  it on pc. Mafi...

Streamlining Java Web Application Deployment with React WAR Generator

In the ever-evolving world of web development, managing builds and deployments can often be cumbersome and error-prone. Today, we're excited to introduce a tool designed to simplify and streamline this process: the React WAR Generator . What is the React WAR Generator? The React WAR Generator is a Python-based tool that automates the creation of WAR (Web Application Archive) files for Java web applications. It caters specifically to frontend projects built with React or similar frameworks, making it easier to package and deploy your web applications to a Tomcat server. Key Features Profile-Based Builds : With support for multiple profiles ( dev , test , prod , default ), you can build your application according to different environments and configurations. Version File Generation : Optionally generate a version file that integrates versioning information directly into your TypeScript files, ensuring your build versions are always up-to-date. Tomcat Deployment : Simplify your deploy...

python program to take nested list input ...(nested list addition ,substraction etc)

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 #!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Tue Mar 13 14:25:56 2018 @author: beast Note this program is for holding int value to list only """ def inmatrix (): matrixA = list () # intialize matrix as empty list try : row,col = [ int (j) for j in ( input ( "Enter the row and col " ) . split())] print (row,col) inp = "" except ValueError : print ( "Please Enter row and col seperated by space eg: 2 2" ) inmatrix() for i in range (row): for j in range (col): inp += (( input ( "Enter the number--->" )) + "," ) try : lst = [ int (a) for a in inp . split( "," ) if a != "" ] #delete int for making it to hold any data ...