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

3g what it is

Definition of 3G: 3G is the third generation of wireless technologies. It comes with enhancements over previous wireless technologies, like high-speed transmission, advanced multimedia access and global roaming. 3G is mostly used with mobile phones and handsets as a means to connect the phone to the Internet or other IP networks in order to make voice and video calls, to download and upload data and to surf the net. How is 3G Better?: 3G has the following enhancements over 2.5G and previous networks: Several times higher data speed; Enhanced audio and video streaming; Video-conferencing support; Web and WAP browsing at higher speeds; IPTV (TV through the Internet) support. 3G Technical Specifications: The transfer rate for 3G networks is between 128 and 144 kbps (kilobits per second) for devices that are moving fast and 384 kbps for slow ones(like for pedestrians). For fixed wireless LANs, the speed goes beyond 2 Mbps. 3G is a set of technologies and stand

Dragon Age: Inquisition Digital Deluxe Edition + All DLCs (torrent) Repack Size: 20.1~23.9 GB

Brief : Dragon Age: Inquisition  is an  action role-playing video game  developed by  Bioware Edmonton  and published by  Electronic Arts . The third major game in the  Dragon Age  franchise,  Dragon Age: Inquisition  is the sequel to  Dragon Age: Origins  and  Dragon Age II . The game was released worldwide in November 2014 for  Microsoft Windows ,  PlayStation 3 ,  PlayStation 4 ,  Xbox 360 , and  Xbox One . Repack Size: 20.1~23.9 GB 

How to Create Your Own Customized Run Commands

The Run command on Microsoft Windows operating system allows you to directly open an application or document with just a single command instead of navigating to it’s location and double-clicking the executable icon. However, it only works for some of the inbuilt Windows programs such as Command prompt (cmd), Calculator (calc) etc. So, have you ever wondered how to create your own customized Run commands for accessing your favorite programs, files and folders? Well, read on to find out the answer. Creating the Customized Run Command: Let me take up an example of how to create a customized run command for opening the Internet explorer. Once you create this command, you should be able to open the Internet explorer just by typing ie in the Run dialog box. Here is how you can do that. Right-click on your Desktop and select New -> Shortcut. You will see a “Create Shortcut” Dialog box as shown below Click on “Browse”, navigate to: Program Files -> Internet Explorer from y

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 your blog. In this tutorial, I

6 Ways to Hack or deface Websites Online

Hello friends , today i will explain all the methods that are being used to hack a website or websites database. This is the first part of the hacking websites tutorial where i will explain in brief all methods for hacking or defacing websites. Today I will give you the overview and in later tutorials we will discuss them one by one with practical examples. So guys get ready for first part of Hacking websites class.... Don't worry i will also tell you how to protect your websites from these attacks and other methods like hardening of SQL and hardening of web servers and key knowledge about CHMOD rights that what thing should be give what rights... Note : This post is only for Educational Purpose only. What are basic things you should know before website hacking? First of all everything is optional as i will start from very scratch. But you need atleast basic knowledge of following things.. 1. Basics of HTML, SQL, PHP. 2. Basic knowledge of Javascript. 3. Basic knowled

What Are Search Engine Spiders?

A spider, also known as a robot or a crawler, is actually just a program that follows, or "crawls", links throughout the Internet, grabbing content from sites and adding it to search engine indexes. Spiders only can follow links from one page to another and from one site to another. That is the primary reason why links to your site (inbound links) are so important. Links to your website from other websites will give the search engine spiders more "food" to chew on. The more times they find links to your site, the more times they will stop by and visit. Google especially relies on its spiders to create their vast index of listings. Spiders find Web pages by following links from other Web pages, but you can also submit your Web pages directly to a search engine or directory and request a visit by their spider. In fact, it's a good idea to manually submit your site to a human-edited directory such as Yahoo, and usually spiders from other search e

How to Show JavaScript or HTML Code on Blogger Blog Posts

How to Display Code on Blogger Posts In order to display codes on blogger blog you should convert them to escaped characters and show them under the HTML tag   pre  as shown below. code in escaped characters Now let us check how to convert a script in to escaped form.  How to Convert HTML/Java Script code in to Escaped Characters You can simply parse a script in to escaped format by following the changes given below. <  must be changed with   < >  should be changed with  > “  should be changed with  " In case if the script is too big to convert manually, you can use any tools which convert a Java script or HTML script in to escaped version. The following links will help you to convert normal HTML and JavaScript codes in to Escaped Characters automatically.  http://www.accessify.com/tools-and-wizards/developer-tools/quick-escape/default.php http://codeformatter.blogspot.in/2009/06/about-code-formatter.html Showing JavaScript and HTML codes in plain text

12 Tips to Maintain a Virus Free Computer

1. Email is one of the common ways by which your computer can catch a virus . So it is always recommended to stay away from SPAM. Open only those emails that has it’s origin from a trusted source such as those which comes from your contact list. If you are using your own private email host (other than gmail, yahoo, hotmail etc.) " then it is highly recommended that you use a good anti-spam software. And finally NEVER click on any links in the emails that comes from untrusted sources. 2. USB thumb/pen drives is another common way by which viruses spread rapidly." So it is always a good habit to perform a virus scan before copying any data onto your computer. NEVER double-click the pen drive to open it. Instead right-click on it and select the option “open”. This is a safe way to open a pen drive. 3. Be careful about using MS Outlook. Outlook is more susceptible to worms than other e-mail programs, unless you have efficient Anti-Virus programs running. Use Pegasus