datatypes in java |Rules of Variables in Java

By | October 18, 2018

datatypes in java| Rules of Variable in java

In this tutorial, I will introduce you to about what are variables, What are data and their types. I will also introduce you about datatypes in java. How to declare and initialize a variable in Java.

datatypes in java

datatypes in java

Variable:

It is  the memory location where we store data

Data:

Collection of Raw forms of facts and figures is called data. Data are something that is in an irregular form.

Types of Data:

Following are the different types of data:

1.Alphabetic Data
(A-z)
2.Numeric data
(0-9)
3.Alpha-Numeric data
(A-z)(0-9)
4.Special Characters

datatypes in java:

int
float number =45.45f         You should use f with float values in java.
String
double
String = value within double quotes

Variable Declaration:

int a = variable declarations ( means to reserve memory)

Variable Initialization:

a=45; variable initialization (means to give some value)

Variable Rules in Java

1. Alphabetic, Number,$ cannot be used in variable names.
2.Cannot start from No.
3. Space is not Allowed.
4. The same Name cannot be used.
5. Keywords cannot be used.
6.Meaningful Name.
7. Should be in camelCase shahabMehmood Whose first alphabet is small and another is Capital khanBahadarKhan

CricketBoard == pascal case whose first word is large and second is small.

nextInt() for int;
nextline() for string;
nextDouble() for double;
nextfloat() for float;

Leave a Reply

Your email address will not be published. Required fields are marked *