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

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...

C++ Program to Find HCF and LCM among 4 numbers (Easiest Logic)

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 #include <iostream> #include <math.h> using namespace std; int main () { int a,b,c,d,i,j,minimum; cout << "Enter the all four number " ; cin >> a >> b >> c >> d; if (a < b && a < c && a < d) minimum = a; else if (b < c && b < d) minimum = b; else if (c < d) minimum = c; else minimum = d; for (j = minimum;; -- j) { if (a % j == 0 && b % j == 0 && c % j == 0 && d % j == 0 ) { break ; } } for (i = 1 ;;i ++ ) { if (i % a == 0 && i % b == 0 && i % c == 0 && i % d == 0 ) break ; } cout << "Lowest Common factor=>" << i << endl; ...

USE any TRIAL SOFTWARE FOREVER WITHOUT SERIAL NUMBER

USE any TRIAL SOFTWARE FOREVER WITHOUT SERIAL NUMBER(most wanted trick) Run a trial software forever now with time stopper you can run a trial software forever no need to fetch for serial numbers,activation codes,patch just DOWNLOAD TIME STOPPER now open it install it click browse select the .exe of the software or file which you want to run forever now simply click create desktop icon and now delete all its existing shortcuts now have fun enjoying software for life time

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...

C++ Program to implement Operator Overloading (>>, <<)

Write a class which contains a string as private data member. Add a member function IsPalindrome that returns TRUE/FALSE depending upon whether the str is palindrome or not. Overload the <> operator to insert the string and print the string respectively along with appropriate message. 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 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 #include #include #include   enum bool { false , true };   class Cpal{      private :          char *str;      public :          Cpal(){}            bool IsPalindrome();      ...

what is LOREM ipsum and why do designers use it

What is Lorem Ipsum? Lorem Ipsum  is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum. Why do we use it? It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using 'Content here, content here', making it look like readable English. Many desktop publishing packages and web page editors now...