What is Java?
Java is a Purely Object Oriented Programming Language. Developed by Sum Microsystem of USA in 1991.It was originally called oak of James Gaslin.
How Java works?
Java is compiled into the bytecode and then it is interpreted to Machine code.
Java installation:
JDK- Java Development Kit is collection of tools used for developing and running Java program.
JRE- Java Runtime Environment it helps in executing programs developed in Java.
Basic structure of a Java Program:
package Com.company; => Group of class
public class Main{
public static Void main(String []args) => Entry point into the Application
{
System.out.println("Hello World"); => Hello World
}}
Naming Conventions:
- For class, we use PascalConvention. First and Subsequent character from a word are Capital Letter(Uppercase).
- For Function and Variables , we use CamelcaseConvention. Here first character is Lowercase and the subsequent character are in Uppercase.
Variable and Data Type:
We have some rules to follow while writing a java program. The set of these rules is called Syntax.
Variables:- A variable is a container that stores a value. This Value can be changed during the execution of the Program.
int number = 55;
int=Data Typenumber=Variable Name55= Value store
Rules for declaring a Variables name:
We can choose while declaring a Java.
- Must not begin with a digit.
- Name is case sensitive.
- Should not be a Keyword.
- Whitespace is not allowed.
- Can contain alphabets, $character, _character and digit if the other condition are specified.
Data Type:
Data type in Java fall under the following condition:
- Primitive Data Type(Intensic)
- Non-Primitive Data Type(Derived)
Primitive Data Type(Intensic):
- Value ranges from -128 to 127
- Takes 1byte
- Default value is 0
- Value ranges from -32768 to 32768
- Takes 2 byte
- Default value is 0
- Value ranges from -2,147,483,648 to 2,147,483,647
- Takes 4 bytes
- Default value is 0
- Value ranges from (docs)
- Takes 4 bytes
- Default value is 0.0f
- Value range from(docs)
- Takes 2 byte
- Default value is 0
- Value range from(docs)
- Takes 8 bytes
- Default value is 0.0d
- Value ranges from 0 to 65535
- Takes 2 bytes
- Default value is '\u0000'
- Value can be true or false
- Size depends on Java
- Default value is false
In order to choose the data type we first need to find the type of data we want to store. After that we need to analyze the min & max value we might use.
Literals: A constant value which can be assigned to the variable is called as a literals.
101=> Integral Literal10.1f=> Float Literal10.1=> double Literal'A'=> Character Literaltrue=> boolean Literal"Sumit"=> String Literal
No comments:
Post a Comment