Thuyein-Thet / Java

Learn Java

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Java

three types of variables in java

(1)local A variable declared inside the body of the method is called local variable. You can use this variable only within that method and the other methods in the class aren't even aware that the variable exists. A local variable cannot be defined with "static" keyword.

(2)instance A variable declared inside the class but outside the body of the method, is called an instance variable. It is not declared as static. It is called an instance variable because its value is instance-specific and is not shared among instances.

(3)static A variable that is declared as static is called a static variable. It cannot be local. You can create a single copy of the static variable and share it among all the instances of the class. Memory allocation for static variables happens only once when the class is loaded in the memory.

two types of data types in java

(1)primitive The primitive data types include boolean, char, byte, short, int, long, float and double

8 Types of Primitive

boolean data type Boolean one = false  
byte data type byte a = 10, byte b = -20  
char data type char letterA = 'A'  
short data type short s = 10000, short r = -5000  
int data type int a = 100000, int b = -200000  
long data type long a = 100000L, long b = -200000L  
float data type float f1 = 234.5f  
double data type double d1 = 12.3  

(2)non-primitive The non-primitive data types include Classes, Interfaces, and Arrays.

Java is a statically-typed programming language. It means, all variables must be declared before its use. That is why we need to declare variable's type and name.

Operators in Java

Unary Operator, Arithmetic Operator, Shift Operator, Relational Operator, Bitwise Operator, Logical Operator, Ternary Operator and Assignment Operator.

Logical && and Bitwise &

Btwise & operator check both condition. Logical && operator check second condition if only the first one is true.

Logical || and Bitwise |

Btwise | operator check both condition. Logical || operator check second condition if only the first one is false.

Java Keywords => https://www.javatpoint.com/java-keywords

Java Control Statements

(1)Decision Making statements if statements switch statement

(2)Loop statements do while loop while loop for loop for-each loop

(3)Jump statements break statement continue statement

Comment

Single line comment in java

//This is a sample of sample line comment in java

Multiline comment in java

/* This is a sample of multiline comment in java This is a sample of multiline comment in java This is a sample of multiline comment in java This is a sample of multiline comment in java */

Documentation comment

/**
* *We can use various tags to depict the parameter *or heading or author name
*We can also use HTML tags
* */

About

Learn Java


Languages

Language:Java 100.0%