Self Learning NOTES
Self Learning NOTES
1. class Simple{
3. System.out.println("Hello Java");
4. }
5. }
Let's see what is the meaning of class, public, static, void, main, String[],
System.out.println().
Types of Variables
local variable
instance variable
static variable
1) Local Variable
2) Instance Variable
A variable declared inside the class but outside the body of the method,
is called an instance variable. It is not declared as static.
3) Static variable
1. public class A
2. {
4. void method()
5. {
7. }
8. public static void main(String args[])
9. {
11. }
3. int a=10;
4. int b=10;
5. int c=a+b;
6. System.out.println(c);
7. }
8. }
Output:
20
3. int a=10;
4. float f=a;
5. System.out.println(a);
6. System.out.println(f);
7. }}
Output:
10
10.0
3. float f=10.5f;
5. int a=(int)f;
6. System.out.println(f);
7. System.out.println(a);
8. }}
Output:
10.5
10
1. class Simple{
3. //Overflow
4. int a=130;
5. byte b=(byte)a;
6. System.out.println(a);
7. System.out.println(b);
8. }}
Output:
130
-126
1. class Simple{
4. byte b=10;
6. byte c=(byte)(a+b);
7. System.out.println(c);
8. }}
Output:
20
Data types specify the different sizes and values that can be stored in the
variable. There are two types of data types in Java:
In Java language, primitive data types are the building blocks of data
manipulation. These are the most basic data types available in Java
language.
There are 8 types of primitive data types:
Example:
Example:
Example:
Example:
Example:
Example:
1. float f1 = 234.5f
Example:
1. double d1 = 12.3
Example:
It is because java uses Unicode system not ASCII code system. The \
u0000 is the lowest range of Unicode system. highest value:\uFFFF.
Operators in Java