Posts

Showing posts from March, 2020

Complete Java masterclass for beginners -09 (If-else statement)

Image
Java If-else Statement The  Java   if statement  is used to test the condition. It checks  boolean  condition:  true  or  false . There are various types of if statement in Java. if statement if-else statement if-else-if ladder nested if statement Java if Statement The Java if statement tests the condition. It executes the  if block  if condition is true. Syntax: if (condition){ //code to be executed          } Example: //Java Program to demonstate the use of if statement.  public class IfExample {     public static void main (String[] args) {          //defining an 'age' variable          int age= 20 ;         //checking the age          if (age> 18 ){   ...

Complete Java masterclass for beginners -08 (Keywords)

Java Keywords Java keywords are also known as reserved words. Keywords are particular words which acts as a key to a code. These are predefined words by Java so it cannot be used as a variable or object name. List of Java Keywords A list of Java keywords or reserved words are given below: abstract : Java abstract keyword is used to declare abstract class. Abstract class can provide the implementation of interface. It can have abstract and non-abstract methods. boolean : Java boolean keyword is used to declare a variable as a boolean type. It can hold True and False values only. break : Java break keyword is used to break loop or switch statement. It breaks the current flow of the program at specified condition. byte : Java byte keyword is used to declare a variable that can hold an 8-bit data values. case : Java case keyword is used to with the switch statements to mark blocks of text. catch: Java catch keyword is used to catch the exceptions generated by try statemen...

Complete Java masterclass for beginners -07 (Operators)

Image
Operators in Java Operator in Java is a symbol which is used to perform operations. For example: +, -, *, / etc. There are many types of operators in Java which are given below: Unary Operator, Arithmetic Operator, Shift Operator, Relational Operator, Bitwise Operator, Logical Operator, Ternary Operator and Assignment Operator. Java Operator Precedence Java Unary Operator The Java unary operators require only one operand. Unary operators are used to perform various operations i.e.: incrementing/decrementing a value by one negating an expression inverting the value of a boolean Java Unary Operator Example: ++ and -- Java Unary Operator Example: ~ and ! Java Arithmetic Operator Example: Expression Java Right Shift Operator The Java right shift operator >> is used to move left operands value to right by the number of bits specified by the right operand. Java Right Shift Operator Example Java Shift Operator Example:...

Complete Java masterclass for beginners -06 (Unicode System)

Unicode System Unicode is a universal international standard character encoding that is capable of representing most of the world's written languages. Why java uses Unicode System? Before Unicode, there were many language standards: ASCII (American Standard Code for Information Interchange) for the United States. ISO 8859-1 for Western European Language. KOI-8 for Russian. GB18030 and BIG-5 for chinese, and so on. Problem This caused two problems: A particular code value corresponds to different letters in the various language standards. The encodings for languages with large character sets have variable length.Some common characters are encoded as single bytes, other require two or more byte. Solution To solve these problems, a new language standard was developed i.e. Unicode System . In unicode, character holds 2 byte, so java also uses 2 byte for characters. lowest value:\u0000 highest value:\uFFFF Next Topic:  Operators In java Happy Coding

Complete Java masterclass for beginners -05 (Data Types)

Image
Data types in JAVA Data types specify the different sizes and values that can be stored in the variable. There are two types of data types in Java: Primitive data types: The primitive data types include boolean, char, byte, short, int, long, float and double. Non-primitive data types: The non-primitive data types include Classes, Interfaces, and Arrays. Java Primitive Data Types: In Java language, primitive data types are the building blocks of data manipulation. These are the most basic data types available in Java language. 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. There are 8 types of primitive data types: boolean data type byte data type char data type short data type int data type long data type float data type double data type Boolean Data Type The Boolean data type is used to store only ...