Presentation is loading. Please wait.

Presentation is loading. Please wait.

 Character set is a set of valid characters that a language can recognise.  A character represents any letter, digit or any other sign  Java uses the.

Similar presentations


Presentation on theme: " Character set is a set of valid characters that a language can recognise.  A character represents any letter, digit or any other sign  Java uses the."— Presentation transcript:

1  Character set is a set of valid characters that a language can recognise.  A character represents any letter, digit or any other sign  Java uses the Unicode character set.  Unicode is a two-byte character code set that has characters representing all characters in almost all languages and writing systems around the world.

2  In Java program, all characters are grouped into symbols called tokens.  OR the smallest individual unit in a program is known as a token.  Tokens are- identifier, keyword, separator, operator, literal and comment.

3  The first category of token is an Identifier.  Identifiers are used by programmers to name things in Java such as variables, methods, fields, classes, interfaces, exceptions, packages, etc.  All characters in an identifier are significant, including the case (upper/lower) of the alphabetic characters. Eg: The identifier Count and count denote different names in Java

4  Identifiers are the names given to different part of the program viz. variables, objects etc.  Forming Rules  Identifiers can have alphabets, digits and underscore and doller sign characters.  They must not be a keyword or boolean literal or null literal.  They must not begin with digit.  They can be of any length.  Java is case sensitive i.e. Upper case and lower case letters are treated differently.

5  Keywords are the second category of tokens in Java.  Keyword sometimes also called as reserved word.  Keywords have inbuilt meaning and the programmers cannot use for other things.  Below are the list of all keywords in Java.

6

7  The third category of token is a Separator.  ;,. ( ) { } [ ]  Eg: Math.max(count,limit);  In the above segment the identifiers are Math, max, count, limit.  And the separators are. (, ) ;

8  The fourth category of token is operator.  The keywords instanceof and new are the part of operators.  Below is the list of the operators in Java.

9

10  The fifth category of tokens is literals.  The values written in Java are called literals.  Example: 1, 3.14, “Hello”, true, ‘a’, null.  int Literals: Literal of the primitive type int represent countable, discrete quantities.  0 is a non zero digit.  1,2,3,4……

11  double Literals: Literal of the primitive type double represent measureable quantities.  Like real numbers in mathematics, they can represent fractions and numbers with decimal places.

12  boolean literals: boolean literal gives one of the two results- true or false.  char literal: This is the first literal of text type.  char literal is enclosed within the single quotes.  Eg: ‘X’, ‘a’, ‘ ‘

13  String literals: The second type of text literal is a String.  Example: “Enter your name”.  This is the only literal that is not of primitive type.  Note that the string is different from char.  String- “X”  char – ‘x’

14  Sometimes you will see an escape- sequence inside the single-quotes for a character-literal or one or more inside double- quotes for a string-literal (see above); each escape sequence is translated into a character that prints in some "special" way.  Some commonly used escape sequences are:

15  \n – new line  \t – horizontal tab  \v – vertical tab  \b – backspace  Eg:  If we output "Pack\nage", Java would print on the console  Pack age

16  null literal: special kind of literal that is used to represent a special value.  Comments : The sixth and final category of tokens is the Comment.  Comments allow us to place any form of documentation inside our Java code. They can contain anything that we can type on the keyboard comment.

17  Comments:  Comments are declared in two ways:  Line-Oriented: begins with // and continues until the end of the line.  Block-Oriented: begins with /* and continues (possibly over many lines) until */ is reached.

18

19  There are two types of data types:  1. Primitive data types  2. Non-primitive data types  Primitive data types: There are eight primitive data types supported by Java.

20  Size: 1 byte.  Range: -128 to 127.  Default value: 0.  Example: byte a = 100;

21  Size: 2 bytes  Range: -32,768 to 32,767  Default value: 0  Example: short s = 1000;

22  Size: 4 bytes  Range: -2,147,483,648 to 2,147,483,647  Default value: 0  Example: int a = 10000;

23  Size: 8 bytes  Range: --9,223,372,036,854,775,808 to 9,223,372,036,854,775,807  Default value: 0  Example: long a=100000L;

24  Size: 4 bytes  Default value: 0.0f  Example: float f1 = 3.14f;

25  Size: 8 bytes  Default value: 0.0d  Example: double d1= 3.14d;

26  boolean data type represents one bit of information.  There are only two possible values: true and false.  This data type is used for simple flags that track true/false conditions.  Default value is false.  Example: boolean one = true

27  Size: 2 bytes  Range: 0 to 65,535  Example: char a=‘A’;

28  Reference variables are created using defined constructors of the classes.  They are used to access objects. These variables are declared to be of a specific type that cannot be changed.  Example: Animal animal = new Animal(“dog");

29  A variable is a named memory location, which holds a data value of a particular data type.

30  int age;  float principalAmount;  int a;  double b;

31  int age = 50;  float principalAmount = 5000;  int a = 10;  double b = 20.0;

32  int age = 50;  int b = age * 10;  int c = age;


Download ppt " Character set is a set of valid characters that a language can recognise.  A character represents any letter, digit or any other sign  Java uses the."

Similar presentations


Ads by Google