Java Notes
Java Notes
Java Notes
JAVA ENVIRONMENT:-->
Print(“hello”);
System. Out .print(“hello”);
Compiler java
Variable:-->
Variable is a named value holder in primary memory.
When a variable is declare the compiler is able to check that it’s not
being use in a manner or context that is a inappropriate to it’s time.
variable name:---->
The name we chose for a variable is called Is
identifier and identifier can be of any length but it must beginning with
in alpha bate(a ,b ,c) & $,&__ the rest of an identifier can include
digits also.
Operator spaces are not allowed in an identifier .
•we can’t use java keywords as a name for something keywords are
words that are essential part of java language.
•java is a case-sensitive language.
Int max, mAx , maX, MAX ; √
ab cd (wrong because space is present, space is not allowed )
ab + cd (wrong)
ab – cd (wrong)
ab @ cd (wrong, because @ not allowed)
while (wrong, loop is present)
While (right √)
ab$123 (right √ )
$ab_123 (right statement )
_ab123(right )
123abs (wrong , because start with digits )
*Calculate Total Marks // class
*calculate Total Maeks // variable
*calculate Total Marks() //method
☹☹☹
Note :::::::: java
{function<-->method} c++
{const<-->final}
{.dlldata link library }
[os + java interpreter => JVM]
Variable literals
Char ch = A;
**String str = ”java”;
Variable literals
Boolean b = true;
COMMENT ::--> comment are non executable statement , that are
ignored by compiler they are use just increase readability of the code.
// single line comment
/*------
--------------------
*/ multiple line comment
•A variable can be declare anywhere in java program just before it’s
use.
•we can spread in a single declaration over several lines .
EX:::---
Int miles = 0 ; // one mile is 8 yards
Furlongs = 0 ; // any comment
Yards =0; // any comment
Feet =0; // any comment
DATA TYPES ::----->>> there are 8 data types defied with in the
language , these fundamental type are also called primitive data types.
•integer data type ::---> these are four data type that can store integer
value.
☹all of these are signed
Data types description size
{1} byte -128 to 127 1 byte
{2} short -32768 to 32767 2 byte
{3} int 2147483648 to 4 byte
2147483647
{4} long -9223372036854775808 8 byte
To
9223372036854775807
*size n bits }calculate size to range
Range -2ki power n-1 to +2 ki power n-1 -1
😉😊
Int no = 23; // decimal no.
Int no =023; // octal no.
Int no =0x23; // hexadecimal no.
Int no = 0b0100; // binary no.