Char and Boolean primitive type

Char and Boolean primitive type
A char is used to store single character  and occupies two bytes of memory, or 16 bits. As char store single character but still  occupies two bytes. The reason is that it allows you to store Unicode characters.


Unicode
:- Unicode is universal encoding standard for different languages, Each character or letter, number, or symbol is assigned a unique value that applicable across any programming language.

In the English alphabet, we have the letters A through Z. Meaning only 26 characters are needed in total to represent the entire English alphabet. But other languages need more characters, and often a lot more.

Unicode allows us to represent these languages and the way it works is that by using a combination of the two bytes that a char takes up in memory.

package com.ekumeedhelp;

public class CharType {

public static void main(String[] args) {
char charValue = 'A';
char unicodeValue = '\u0045';
System.out.println(charValue);
System.out.println(unicodeValue);

}

}



Boolean :- A boolean value is either True or False, Yes or No, 1 or 0. In Java terms we have a boolean primitive type and it can be set to two values only. true or false They are actually pretty useful and you will use them a lot when programming

package com.ekumeedhelp;

public class BooleanType {

public static void main(String[] args) {

boolean trueBooleanValue = true;
System.out.println(trueBooleanValue);

boolean falseBooleanValue = false;
System.out.println(falseBooleanValue);

}

}

Float and Double primitive type.

Float and Double primitive type.
Floating number : - Unlike Integer number floating number has fraction part or decimal. Ex - 3.23434


We used floating when more precision is needed. In java we have two primitive type number to represent floating number are Float and Double. Float is single precision number while double s double precision number. Here precision means format and size(Space). 

Now you know float is single precision and it occupies 32 bits space where as Double is double precision and occupies 64 bits.


package com.ekumeedhelp;

public class PrimitiveDataType2 {

public static void main(String[] args) {

float minFloatValue = Float.MIN_VALUE;
float maxFloatValue = Float.MAX_VALUE;

System.out.println("Min Float Value : " + minFloatValue);
System.out.println("Max Float Value : " + maxFloatValue);

double minDoubleValue = Double.MIN_VALUE;
double maxDoubleValue = Double.MAX_VALUE;

System.out.println("Min Double Value : " + minDoubleValue);
System.out.println("Max Double Value : " + maxDoubleValue);

}

}

Variables & Data Type in Java

Variables & Data Type in Java


Variables :-
 Variable are a way to store information in our computer random  access memory(RAM). A variable means that can be changed. Java support different type of variables like int, long, double etc.. collectively  these are knows as Data Type.

While declaring variable we must have to tell the type of variable to computer. Lets start defining a variable to store whole number without decimal.

Syntax to define variable 

<Type> <Variable Name> = <value>

int myFirstNumber = 10;

Here int is the type of variable in Java which mean integer, that store whole number and myFirstNumber is the variable name which is used to access the variable and finally assigned 10 value into myFirstNumber variable.


Data Type :- In Java  data type in divided into two categories.
  1. Primitive
  2. Non-Primitive 
Total we have 8 primitive type(int,short,long,byte,float,double,boolean,char).

 Data Type     Size 
 boolean     1 bit
 char                     2 byte              
 byte 1 byte
 short 2 byte
 int 4 byte
 long 8 byte
 float 4 byte
 double 8 byte

package com.ekumeedhelp;

public class PrimitiveDataType1 {

public static void main(String[] args) {
int minIntValue = Integer.MIN_VALUE;
int maxIntValue = Integer.MAX_VALUE;

System.out.println("Min Int Value : " + minIntValue);
System.out.println("Max Int Value : " + maxIntValue);

short minShortValue = Short.MIN_VALUE;
short maxShortValue = Short.MAX_VALUE;

System.out.println("Min Short Value : " + minShortValue);
System.out.println("Max Short Value : " + maxShortValue);

byte minByteValue = Byte.MIN_VALUE;
byte maxByteValue = Byte.MAX_VALUE;

System.out.println("Min Byte Value : " + minByteValue);
System.out.println("Max Byte Value : " + maxByteValue);

long minLongValue = Long.MIN_VALUE;
long maxLongValue = Long.MAX_VALUE;

System.out.println("Min Long Value : " + minLongValue);
System.out.println("Max Long Value : " + maxLongValue);

}

}

Test

Hello Java program

Hello Java program
In this post we will learn about Hello Java program and try to understand with example.

1
2
3
 public class Hello {

}

Like other programming language Java programs also have keywords. Each keywords has specific meaning and sometime used in some specific orders. keywords are case sensitive like public and Public and even PUBLIC all are totally different.

With the help of keywords and certain rule we can write statements which collectively form java program.

In the above program you can see public and class are two keywords in green and Hello is the name of the class. lets try to understand the meaning of both keywords.

public :- In java programming public is the access modifier is allow us to define the scope or you can also say how other part of the program access this code. For example  public bus that means it is available for everyone i.e scope is for everyone. So here our class is public means available for every other class.

class :- To define a class we need the class keywords. In above example Hello is the class name and defined using class keyword and whatever you can write withing both left and right curly braces are called as class body.  


 

Java Tutorial for beginners

Java Tutorial for beginners
Hi Guys, Welcome to the Java tutorials for beginners.In this tutorials series you will learn core Java concept in depth. To join free Java class join my telegram channel and also subscribe my YouTube channel using below link. 


 What is Java?

  • Java is a programming language was developed by Sun Microsystems in 1995.
  • James Gosling is known as the father of Java.
  • Java is high level programming language.
  • Java is object oriented programming language.
  • Object-oriented programming (OOPs) is a methodology or rules
  • OOPs concepts are: [Class, Object, encapsulation, Abstraction, polymorphism, Inheritance]

Java JDK and eclipse installation and setup

In this post we you will learn how to install and setup Java 11 & 14 and eclipse software in 64 bit windows 10 machine.

To start programming in java you must have Java install in your machine.
Download JDK 14 or JDK 11 as per your your machine like windows or linux and check out the video and follow the step.


How to setup eclipse in windows 10 machine.